Skip to main content
New Participant
Jul 4, 2022 10:43 AM UTC
Question

How to use more record fields in "sortField" of read only grid (Grid uses record data)

My read only grid is having a column "Emp - Name" where we are concatenating Emp First Name and Emp Last Name and showing under a single column "Emp - Name". Here how to sort this column "Emp - Name" by clicking on the Header with both Emp Last Name and Emp First Name (First sort with Emp First Name then with Emp Last Name).

"sortField" parameter is accepting only one record type field (In this case, i'm able to use either the firstname or the lastname to sort)

Please advise.

2 replies

vinayk2390
Participating Frequently
Jul 4, 2022 12:24 PM UTC

You can use the initialSorts parameter in expression mode or edit as expression for sort in design mode. This will accept multiple sorts.
As for the header click sort on demand, can you elaborate on use case here as sorting both fields by clicking on individual headers does not make much sense. We can have full name as a new column that will sort the entire name if required by adding this attribute in DB table as well.

initialSorts: {
      {
        a!sortInfo(
          field: 'recordType!{...}Record A.fields.{firstName}firstName',
          ascending: true
        ),
        a!sortInfo(
          field: 'recordType!{...}Record A.fields.{lastName}lastName',
          ascending: true
        )
      }
    }

stefanhelzle0001
Brainy
Jul 4, 2022 12:35 PM UTC

Is this a synced Record? If yes, create a custom field holding these joined values and sort on it.