Live Pagination
InfiniteTable supports live pagination in its DataSource via the livePagination prop together with livePaginationCursorSpecify
DataSource.livePagination=true and provide a pagination cursor (a good cursor would be the id of the last item in the DataSource).In addition, you have to listen to
onDataParamsChange which will be triggered with an object that contains the following properties:sortInfo- information about the current sort stategroupBy- current grouping infolivePaginationCursor- the current pagination cursor
When
dataParams change (you will be notified via onDataParamsChange), you have to fetch new data using the cursor from dataParams object.onDataParamsChange trigger
Basically
onDataParamsChange is triggered whenever props (and state) that affect the DataSource change - be it via sorting, filtering, live pagination, pivoting, etc.Below you can see a live pagination demo implemented in combination with react-query.
#
Live pagination - with react-query
loading demo…
In the example above, play around and scroll the table and also make sure to try sorting (eg: sort by country or city).
For demo purposes, the page size in the example above is small - it shows that
InfiniteTable handles infinite pagination correctly by immediately triggering onDataParamsChange when there are not enough rows to fill the viewport.On the other hand, when there are many rows and there is a horizontal scrollbar, it triggers
onDataParamsChange only when the user scrolls to the end of the table.It also handles the case when there is a vertical scrollbar and then the user resizes the viewport to make it bigger and no more vertical scrollbar is needed - again
onDataParamsChange is triggered to request more rows.