You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jul 4, 2021. It is now read-only.
Repository navigation
This repository was archived by the owner on Jul 4, 2021. It is now read-only.
We're using a project with OData currently. But it would be nice to have this project support the "$skip" param instead of the current "currentpage" param.
OData uses "$top" (pagelimit) and "$skip" (currentpage * pagelimit) to create data offsets. It's a simple implementation next to the current and would be nice to have!
I too ran into this problem. I had to implement my own solution:
state: {firstPage: 0,currentPage: 0,pageSize: 5,offset: 0},queryParams: {pageSize: 'limit',// LIMIT in SQL speakstart: 'after'// OFFSET in SQL speak},getOffset: function(){console.log('getOffset:',this.state);returnthis.state.currentPage*this.state.pageSize;},fetch: function(options){if(!options){options={};}if(options['data']){options['data']['after']=this.getOffset();}else{options['data']={'after': this.getOffset()};}returnPaginatedCollection.prototype.fetch.call(this,options);}
All the terminology here is annoying if you're used to offset/limit terminologies. The API I'm using uses the terms "after/limit" while backbone.paginator uses "start/pageSize" but SQL uses "offset/limit".
So far this seems to work as expected but do I get unnecessary query params in my API request. I can live with that...
If I'm not wrong, the example from the readme solves this nice and succinctly? (I think that's where I first found it?)
queryParams: {pageSize: "limit",// Setting a parameter mapping value to null removes it from the query stringcurrentPage: null,// Any extra query string parameters are sent as is, values can be functions,// which will be bound to the pageable collection instance temporarily// when called.offset: function(){returnthis.state.currentPage*this.state.pageSize;}},
Activity
mookfist commentedon Sep 19, 2017
+1
dealing with an API that uses offset/limit rather than page/limit
alex-dow commentedon Sep 20, 2017
I too ran into this problem. I had to implement my own solution:
All the terminology here is annoying if you're used to offset/limit terminologies. The API I'm using uses the terms "after/limit" while backbone.paginator uses "start/pageSize" but SQL uses "offset/limit".
So far this seems to work as expected but do I get unnecessary query params in my API request. I can live with that...
jackbentley commentedon Jan 31, 2018
If I'm not wrong, the example from the readme solves this nice and succinctly? (I think that's where I first found it?)