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.The demo below is implemented in React, in combination with react-query. In Vue the same props are used: keep the rows loaded so far in a
ref and bind it to data, and when onDataParamsChange is called with a new livePaginationCursor, fetch the next page and add its rows to the ref.#
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.