See also: Paging records in the UI
Paging through a list of records using a Form element is quite convenient in some cases. For example where there are too many fields to be presented as table columns. A simple application may look like this:
We will now build a simple application that enables such behavior.
1. Consume the function returning the list of records, in this case a BI Service:
2. Add a Data Share element to the model and connect it to the output port of the service.
3. Add a new field called order to the Data Share to define the numbering of each record. As the user uses the application we update this number for each record (1, 2, 3…) so we could later find it.
4. Connect a Form View element to the Data Share.
5. Add a Data Store element to the model, and define two Fields: max for the number of the last record, current_index for the current record presented in the Form View. This field should update as the user moves through the records (1, 2, 3…).
6. Connect an Aggregate Operator to count the number of records.
7. Connect the Operator to the Data Store and define the Fields mapping:
8. Go to the Layout Board, define a toolbar for the Form View, and add two buttons for the Next and Previous operations (you could change the button text as follows).
9. Define the Action for the Next button. First give the current index to the current record:
Then assign an incremented value to the current index:
Finally use the FIND Action to get to the next record:
Note that if we have only one button with the FIND Action only, we get a cyclic traversal of the records.
10. Define Action for the Previous button. First assign a decremented value to the current index:
Then use the FIND action to get the record where the order is the same as the changed current index:
11. Define Enable condition for the previous button: prevent trying to get records with order lower than 1:
12. For the Next button define in the same manner, don’t allow to pass the maximum order number: