If you are dealing with large amounts of data, your applications may decide to use pagination to help the user navigate through the data.
Pagination is enabled in the grid via the
pagination grid option. The pagination page size is
typically set alongside this using the
paginationPageSize option. These options are shown below:
For more configuration details see the section on Pagination.
Pagination on the Server
The actual pagination of rows is performed on the server when using the Server-Side Row Model. When the grid needs
more rows it makes a request via
getRows(params) on the
Server-Side Datasource with
metadata containing pagination details.
The properties relevant to pagination in the request are shown below:
endRow requested by the grid may not actually exist in the data so the correct
lastRowIndex should be supplied in the response to the grid. See
Implementing the Server-Side Datasource for more details.
Example: Server-Side Pagination
The example below demonstrates server-side Pagination. Note the following:
Pagination is enabled using the grid option
A pagination page size of 10 (default is 100) is set using the grid option
The number of rows returned per request is set to 10 (default is 100) using
endRowproperties in the request are used by the server to perform pagination.
- Use the arrows in the pagination panel to traverse the data. Note the last page arrow is greyed out as the last row index is only supplied to the grid when the last row has been reached.
- Open the browser's dev console to view the request supplied to the datasource.
Pagination with Groups
When grouping, pagination splits rows according to top-level groups only. This has the following implications:
- The number of pages is determined by the number of top-level rows and not children
- When groups are expanded, the number of pagination pages does not change.
- When groups are expanded, all children rows appear on the same page as the parent row.
The example below demonstrates pagination with grouping. Note the following:
- No block size is specified so 100 rows per block is used.
paginationAutoPageSize=trueis set. This means the number of displayed rows is automatically set to the number of rows that fit the vertical scroll, so no vertical scroll is present.
- As rows are expanded, the number of visible rows in a page grows. The children appear on the same row as the parent and no rows are pushed to the next page.
- For example, expand 'Australia' which will result in a large list for which vertical scrolling will be needed to view all children.
Pagination with Child Rows
If it is desired to keep the row count exactly at the page size, then set grid property
This will have the effect that child rows will get included in the pagination calculation. This will mean if a group is expanded, the pagination will split the child rows across pages and also possibly push later groups into later pages.
The example below demonstrates pagination with grouping and
paginateChildRows=true. Note the following:
- No block size is specified thus 100 rows per block is used.
paginationAutoPageSize=trueis set. This means the number of displayed rows is automatically set to the number of rows that fit the vertical scroll.
- As rows are expanded, the number of visible rows in each page is fixed. This means expanding groups will push rows to the next page. This includes later group rows and also its own child rows (if the child rows don't fit on the current page).
If the last visible row is expanded, the grid gives a confusing user experience, as the rows appear on the
next page. So the user will have to click 'expand' and then click 'next page' to see the child rows. This
is the desired behaviour as the grid keeps the number of rows on one page consistent. If this behaviour
is not desired, then do not use
Continue to the next section to learn about Row Selection using the Server-Side Row Model.