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
(dataParamsChange) 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 (dataParamsChange)), you have to fetch new data using the cursor from dataParams object.onDataParamsChange trigger
Basically
(dataParamsChange) 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. It keeps the rows loaded so far in a signal bound to
data, and when (dataParamsChange) emits a new livePaginationCursor, it fetches the next page and adds its rows to the signal.#
Live pagination
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 (dataParamsChange) 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
(dataParamsChange) 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
(dataParamsChange) is triggered to request more rows.