Pagination and sorting are the features you get automatically if you create a table by dragging an Entity to the Screen. However, you may choose to implement pagination and sorting manually. Here are the instructions to help you with that.
In these instructions we use data from an Aggregate. If you use "Fetch from Other Sources" to get the data, you should implement your own logic.
Follow these steps to add pagination to your table. You should already have an Aggregate and a Table Widget added to your Screen.
- Create MyStartIndex and MyMaxRecords Local Variables of the Integer Data Type. Set the default values of these variables.
In the properties of the Aggregate that fetches your data set StartIndex to MyStartIndex, Max. Records to MyMaxRecords.
Drag the Pagination Widget below the Table Widget and set StartIndex to MyStartIndex, MaxRecords to MyMaxRecords. Also, set TotalCount to the Output Parameter
.Countof the Aggregate.
Still in the Pagination Widget properties, from the Handler drop-down list box select New Client Action. Action PaginationOnNavigate opens.
In the Action PaginationOnNavigate assign the value of the NewStartIndex Input Parameter to MyStartIndex (MyStartIndex = NewStartIndex). Drag a Refresh Data Tool to the Flow and set it to refresh the Aggregate.
Go back to the Pagination Widget properties and confirm that the NewStartIndex property is set to NewStartIndex from the Event.
- Publish the module.
Service Studio automatically creates Actions for sorting the columns in a Table. This makes it quick to change how the sorting works, or remove it completely.
Add sorting to a Table
In the OnSort drop-down list box of your Table Widget properties, select New On Sort Client Action. A new Action is created with the sorting logic. At this step all table columns are sortable and you can publish the module.
Change sorting Attribute
You can change the Attribute used for sorting.
- In the Widget Tree, locate the Header Cell of the row you want to sort by (or select the cell in the content editor).
In the Sort Attribute drop-down combo box select the Attribute for sorting.
Publish the module.
To remove the sorting feature from the table column, delete the value of the Sort Attribute parameter of the Header Cell element.