When you navigate, server-side pagination requests that each page be loaded individually. The server must support pagination before the client can request data sets with specified page sizes, page indexes, and possibly sorting and filtering criteria. The server then returns the appropriate subset. Server-side pagination manages large amounts of data while maintaining stability and scalability.
Server-Side Pagination has the following advantages
It can handle large data sets.
Quicker initial page load.
Reduce network latency to improve page load time
Server-side pagination in Mendix can be accomplished using Data Grids, either Data Grid 1 or Data Grid 2. This blog will demonstrate how to use Data Grid 1 to achieve server-side pagination.
As shown in the image below, create a Microflow that retrieves activity from the database or from the association. This retrieves the data that will be displayed in the grid. Later, you can change the number of data points that appear on the grid.
Once you create a microflow for data retrieval, select the data grid from the toolbox and copy it into the UI/Page. It will throw an error by default, as shown in the image below. To address this, we must first use a data source.
Now select data source as microflow which we have created before.
After selecting the microflow, you will be taken to the page below, where you will be asked to generate the controls for server-side pagination. Click Yes.
This will generate all of the required nanoflows and pagination controls, as shown in the image below.
The module will then throw an error in the error list.
To resolve this, we must modify our previously created microflow. We must configure the data return list to List.
We now need to specify how much data should be loaded into the page. This is done in the retrieve option, where we can specify the number of rows to load in the grid per page.
The offset must then be specified. The offset can be specified as shown below. The number 20 represents the amount of data required per page.
After you’ve completed all of the steps, your server-side pagination is ready to use.
See how we assisted a Middle Eastern Government organization in our success story.
We ran into some issues while implementing server-side pagination. The challenges are as follows:
We are retrieving data from the microflow page by page. We won’t know how much data is left to load because we aren’t retrieving the entire database.
To get around the above limitation, we calculated the count while the page was loading by using Aggregate list operations.
There will also be no navigation button to jump to the last page of the grid. This must be done manually by calculating the total number of data in the data source and then calculating the total number of pages in the grid.
If you use Advanced Search or any filter options, we must redirect the grid page to the first page whenever we use them.