Combining two data fields when exporting from data grid

Hi,

I have two separate columns in a database table - first name and last name - that I am representing in a Radzen Datagrid with the option of exporting to XLSX. I would like two combine the data in these two fields so that it appears in a single column - full name - in the XLSX export.

This is my code as it stands:

public async Task ExportExpenseRecords(string type)
        {
            await _exportService.Export("expense-records-paid", type, new Query()
            {
                OrderBy = expenseRecordGrid.Query.OrderBy,
                Filter = expenseRecordGrid.Query.Filter,
                Select = "CreateDate, Expense.User.FirstName, Expense.User.LastName, ExpenseType.Name AS ExpenseType, ExpenseReason, Amount"
            });
        }

I have tried various things to get the first name and last names to export to a single column but so far haven't had any luck. Is this possible?

Try changing to

public async Task ExportExpenseRecords(string type)
        {
            await _exportService.Export("expense-records-paid", type, new Query()
            {
                OrderBy = expenseRecordGrid.Query.OrderBy,
                Filter = expenseRecordGrid.Query.Filter,
                Select = "CreateDate, Expense.User.FirstName+Expense.User.LastName as UserName, ExpenseType.Name AS ExpenseType, ExpenseReason, Amount"
            });
        }

Thanks @Vinod_Pillai but unfortunately that doesn't work.

When I look at the network tab and click on the call to API it shows this as the response:

')' or ',' expected (at index 40)

I've used the example here to sort it:

I've updated my controller to use an anonymous type like so:

[HttpGet("/export/expense-records-paid/excel")]
        public async Task<IActionResult> ExportPaidExpenseRecordsToExcel()
        {
            var claimsPrincipal = User;
            var companyId = claimsPrincipal.FindFirst(c => c.Type == "companyId");

            if (companyId != null)
            {
                var data = context.expense_records.Where(x => x.DeleteDate == null && x.UserMarkedPaidDate == null
                && x.Expense!.Status == Status.AwaitingReimbursement.ToString() && x.Expense!.CompanyId == int.Parse(companyId.Value))
                    .Select(x => new { FullName = x.Expense.User.FirstName + " " + x.Expense.User.LastName });

                var result = await ToExcel(ApplyQuery(data, Request.Query));

                return Ok(result);
            }

            return NoContent();
        }

and then I've updated my call to the export service accordingly:

public async Task ExportExpenseRecords(string type)
        {
            await _exportService.Export("expense-records-paid", type, new Query()
            {
                OrderBy = expenseRecordGrid.Query.OrderBy,
                Filter = expenseRecordGrid.Query.Filter,
                Select = "FullName"
            });
        }

Just need to go through and add back in the missing fields now.