DataProvider - using cursor rather than offset

Hi,

I’m wondering if there is any way of using a cursor with Grid or DataProvider instead of offset/limit.

I’d like to be able to have the Grid mange pagination with cursors, and have my backend decide whether to implement it with limit/offset or other filters depending on the data.

Is there any intention of supporting cursor-based pagination?

Hi!

This is not a priority in the ongoing DataProvider enhancements, but might make implementing this later on easier. What would your backend be like? JDBC cursor or something else? If you can a good usage example to share, let’s create an enhancement issue for this.

cheers,
matti

I was thinking of allowing a string to be sent to the backend as a cursor, and the backend returning a nextCursor string.

It’s an approach that seems quite ubiquitous, and supports any type of pagination by simply encoding the data required into a base64 or otherwise opaque string. This would then support:

  • Limit/offset
  • ElasticSearch search_after or similar with RDBMS
  • ElasticSerach cursor or DB cursor.

https://slack.engineering/evolving-api-pagination-at-slack-1c1f644f8e12
https://www.elastic.co/guide/en/elasticsearch/reference/6.8/search-request-search-after.html
https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-body.html#request-body-search-scroll