React-admin: Allow non numeric pagination

Created on 26 Apr 2018  路  5Comments  路  Source: marmelab/react-admin

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

enhancement

Most helpful comment

@fzaninotto

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.

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.

All 5 comments

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 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.

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?

Was this page helpful?
0 / 5 - 0 ratings