Most of the times you don't want to display database records in an arbitrary order. Either you want to display the records sorted in a predetermined way, or you want to allow end-users to customize how records are sorted.

To sort the records by the values of a column, hover over the column, click , and choose 'Sort A->Z' or 'Sort Z->A'. If you want to sort by multiple columns at the same time, simply do the same for the other columns.

At any time, you can view and edit the sorting applied to your aggregate under the tab.

Sorting by Columns

To sort Products first by their name, and then by their price:

  1. Drag the Product Entity to the aggregate;
  2. Hover over the Name column, click and choose 'Sort A->Z'. The Products are displayed in alphabetical order;
  3. Hover over the Price column, click and choose 'Sort A->Z'. For products with the same name, the product with the lowest price is displayed first.

Dynamic Sort

You have the possibility to sort by a column defined in a variable.

This enables your users to choose at runtime by which columns to sort the records:

  1. Click 'Add Dynamic Sort' in the Sorting tab;
  2. Provide a text value specifying which column you want to sort. The text syntax depends on the aggregate column's type:

It's an Entity Attribute

Use "{Entity}.[Attribute]" for ascending order or "{Entity}.[Attribute] DESC" for descending order.

It's a Calculated Column

Use "<AttributeName>" for ascending order or "<AttributeName> DESC" for descending order.

For example, to sort by the date of birth of clients, use "{Client}.[DateOfBirth]" to sort ascending or "{Client}.[DateOfBirth] DESC" to sort descending.


To display a table with the Products in the database, while enabling users to sort the records by a column of their choice, follow these steps:

  1. Add an aggregate to the preparation action of the screen, and drag the Product entity to it;
  2. Drag a TableRecords to the screen, and set its 'Source Record List' property with the GetProducts.List value;
  3. Drag the Products entity to the TableRecords, name it MyProductsTable;
  4. From the RichWidgets folder in the Interface tab, drag a List_SortColumn widget next to each column name of the TableRecords;
  5. Set each List_SortColumn 'Column' property to "<attribute_name>". Example: "Name";
  6. Add a screen action to the screen, and implement the logic that refreshes the aggregate results and the table. Learn more about how to refresh data;
  7. In the TableRecords, set each List_SortColumn widget's 'Destination' property to the new screen action;
  8. In the Sorting tab of the aggregate, click on 'Add Dynamic Sorting', and type List_SortColumn_GetOrderBy(MyProductsTable.Id,"{Product}.[Name]")

See Also

Fetching Data | Filtering Results | Aggregate Properties