Hello marmelab!! first of all thank you for this amazing project.
What you were expecting:
I am using react admin to display data from an api which has pagination of the form lastEvaluatedKey (like dynamodb, cloudsearch). This is a string
What happened instead:
Currently there is no way that I can pass this string value to the pagination module
Clearly the <Pagination> component fits only APIs using numeric paginations.
But nothing prevents you from creating your own "load more" component, which calls the setPage prop with a non-numeric page identifier, and use it instead of <Pagination> inside <List>. You'll also need to implement your API pagination logic in a custom data provider.
Or am I missing something?
If nothing prevents your from doing it in userland, I'll close this issue, as I don't think we'll maintain that ability in core. Feel free to publish your custom pagination container as a standalone package and mention it in react-admin's doc.
@fzaninotto was there anything further from this? i'm looking to create a custom pagination component that works off of cursors - which comes with customizing a data provider as you've indicated. however, if someone else has done something similar already, i'd rather not recreate something that exists. let me know.
if not, i'll try and see if i can publish it as a standalone component.
Nothing that I have heard of.
@fzaninotto
But nothing prevents you from creating your own "load more" component, which calls the
setPageprop with a non-numeric page identifier, and use it instead of<Pagination>inside<List>. You'll also need to implement your API pagination logic in a custom data provider.
I recently attempted this but the implementation inside ListController prevents non-integer paging, as it performs a parseInt(), resulting in NaN for any non-numeric values before they get to a dataProvider.
What would you think of changing the parseInt() to a JSON.parse(), it would have no impact for the existing integer logic but would also open up customisation using arbitrarily complex paging payloads.
@fzaninotto , setPage() resulting with NaN,
can you re-open the issue?
Most helpful comment
@fzaninotto
I recently attempted this but the implementation inside ListController prevents non-integer paging, as it performs a
parseInt(), resulting inNaNfor any non-numeric values before they get to a dataProvider.What would you think of changing the
parseInt()to aJSON.parse(), it would have no impact for the existing integer logic but would also open up customisation using arbitrarily complex paging payloads.