Sort Data in Table Columns

Sorting is enabled by default on all table columns. Simply use the up and down icons on the table headers in Live mode to arrange the column's data in either ascending or descending order:



Sort table data by a particular column

If you want your table to always sort data based on a particular column (for example, ID), you can use the sortCriteria parameter in the Service Data Provider (SDP) used to retrieve the table's data.

  1. In the Variables tab, locate the SDP variable underlying the table, for example, departmentListSDP.
  2. In the variable's Properties pane, select sortCriteria under Parameters.
  3. On the Target pane of the Map Variables to Parameters dialog, expand sortCriteria and item[i] to view the attribute and direction options.
    1. Select attribute, then enter the name of the field you want to sort in the expression builder; for example, id.
    2. Select direction, then enter the direction of the sort, either asc for ascending or dsc for descending. If you don't specify a value, the default direction (asc) is used for sorting.


    You can add several sort criteria in the array to define sorting by multiple columns. For example, to sort by location first and then by department, you'd use:
    [
     {
      "attribute": "location",
      "direction": "dsc"
     },
     {
      "attribute": "departmentName",
      "direction": "asc"
     }
    ]
  4. Click Save.

With sortCriteria specified on the ID column in the descending direction, your table sorts data by default on the ID column in the descending order, as shown here:
Description of sortcriteria-table-defaultcolumn.png follows
Description of the illustration sortcriteria-table-defaultcolumn.png

Disable sorting on a column

If you want to remove sorting capabilities on a particular column:
  1. Select the table on the page to view its properties.
  2. Click the Data tab.
  3. Under Table Columns, click Column Detail (View Detail icon) for the column on which you want to disable sorting.
  4. Set Columns, Sortable to Disabled.

Sorting in Parent-Child Relationship Tables

When working with tables in a parent-child hierarchy, sorting will work as expected on the parent table's columns. To sort records on the child table's columns, some additional steps are required.

Let's say you have a table that displays data for departments and the department's employees in a Departments table (parent table). When end-users select a department in the Department table, the selection determines the list of employees that appears in the Employee table (child table). To sort records by the child table's columns, the table must be based on the child objects and fetch parent details for each child (employees, in our example). The accessor in the relationship between the Department and Employee business objects must also be enabled. In the case of employees in a department, this would be the accessor on the Employee business object that allows access to Department information:
Description of parentchildtables-accessor.png follows
Description of the illustration parentchildtables-accessor.png

See Edit a Business Object Relationship for steps on editing the relationship to enable the accessor.