Reputation: 1275
My back-end API supports cursor based pagination for the GET_LIST operations.
API: {apiUrl}/{resource}?fltr={limit:100}
Response:
{
data: [],
next: {reference_url_to_the_next_paginated_data_set}
}
What is the best way to supported this sort of pagination with the existing AOR pagination infrastructure ?
Upvotes: 2
Views: 1064
Reputation: 1275
I ended up achieving this using a Custom Saga, Action creator and Reducer.
A Connected Pagination Component that is subscribed to the pagination state of that resource, that has a "next" and "previous" button and a "currentPage" state. On-Click of "Next" or "Previous" buttons, fetch the "nextUrl" or the "previousUrl" for the "currentPage" and use AOR's fetch-meta to update the "data" state of that resource.
Use this custom Pagination component in your data-grid like so
<List resource="myResource" pagination={<CustomPagination />} />
Upvotes: 1
Reputation: 1283
You need to write a custom Rest client to handle your response and request type. You need your API to set the X-Total-Count header when your client makes a GET_LIST type request.
https://marmelab.com/admin-on-rest/RestClients.html
Upvotes: 0