Blog
Gallery Control - How to Paginate Data
May 7. 2018
Here's the best sample app that shows how to page and add previous and next buttons to a gallery.
If you need to need to add paging functionality to a gallery control,
This is an excellent app that demonstrates many useful techniques, including searching (by record number and page number), and also labels to show the total records count, page number, and total page numbers. Here's a very brief summary of how this app works.
The first part of
To populate the data for any given page, the syntax of the Gallery control's Item property looks like this:
LastN(FirstN(DataSource, TotalRecordCountForCurrentPage), NumberOfRowsPerPage)
TotalRecordCountForCurrentPage is a numeric variable equal to this:
Current page number * Number of rows per page
The LastN/FirstN syntax displays the last batch of records for TotalRecordCountForCurrentPage, which equates to the batch of records that corresponds to the current page number.
The formula for the 'next page button' increments the TotalRecordCountForCurrentPage variable by the NumberOfRowsPerPage.
UpdateContext({TotalRecordCountForCurrentPage:TotalRecordCountForCurrentPage + NumberOfRowsPerPage}))
Conversely, the 'previous page button' decrements the TotalRecordCountForCurrentPage variable by the NumberOfRowsPerPage.
UpdateContext({TotalRecordCountForCurrentPage:TotalRecordCountForCurrentPage + NumberOfRowsPerPage}))
In
The 'first button' displays the first set of records by setting TotalRecordCountForCurrentPage to the NumberOfRowsPerPage.
UpdateContext({TotalRecordCountForCurrentPage:NumberOfRowsPerPage}))
The 'last button' displays the last batch by setting TotalRecordCountForCurrentPage to the total row count of the record source.
UpdateContext({TotalRecordCountForCurrentPage:CountRows(DataSource)}))
This is just the brief overview of how this works, and I recommend that you visit the forum post to see the full details. Well done PK!
- Categories:
- controls
- sums totals
Related posts
- Controls - How to workaround the bug when setting Radio Button fill color dynamically
- Controls - How to build a control to enter measurements in inches with fractional units
- Controls - How to build a component for users to enter numbers with a set of connected slider and text input controls
- Controls - How to use the Tab List control - Examples
- Controls - How to set height of nested galleries dynmically
- Barcodes - How to scan barcodes - a summary of the 3 available barcode scanning controls
- Controls - How to create multi-line tooltips or multi-line text input control hint text
- Controls - How to add a clickable image / image button
- Controls - Restrict text input control to whole numbers only
- Controls - How to submit a form (or to run formula) when a user presses enter/return on the keyboard
- Controls - How to create rounded labels - workaround
- Controls - How to enter and display Office/Microsoft 365 email addresses with a combo box
- Gallery control - How to set no selected item in a gallery
- Model Driven App - How to apply an input mask to a text input field
- Controls - How to reset or clear data entry controls, and form values
- Controls - How to Transition/Show/Hide controls with a Sliding Effect