Loopback and pagination on listView
See original GitHub issueHi again, I got a question related to https://github.com/marmelab/ng-admin/issues/414 I’m actually using loopback and the customParams to manage pagination on my listViews:
RestangularProvider.addFullRequestInterceptor(function(element, operation, what, url, headers, params) {
if (operation === "getList") {
// custom pagination params
if (params._page) {
params['filter[limit]'] = params._perPage;
params['filter[skip]'] = (params._page - 1) * params._perPage; //skip is the same os offset
delete params._page;
delete params._perPage;
}
return {params: params};
}
});
And my listView is defined like this:
post.listView()
.title('Posts List')
.perPage(10)
.infinitePagination(false)
...
.listActions(['show', 'edit', 'delete']);
I have access to all Posts while browsing all pages one by one : http://[…]/bower_components/#/Posts/list?page=2, http://[…]/bower_components/#/Posts/list?page=3, etc. But my problem is that the pagination always shows 1 - 10 on 10 on all pages (and not 1-10 on 25 as I expected) - and the buttons of the other pages are not displaying. -> I guess the total-items count must not be equal to the per-page count in this case, but i’m not able to change this in any ways.
If I remove the .perPage(10) attribute, I can see all my 25 Posts (1 - 25 on 25). Do you think it is a problem with loopback, or the latest branch of ng-admin - or should I search for another solution? Help is greatly appreciated 😃 Thanks in advance, Felix.
Issue Analytics
- State:
- Created 8 years ago
- Comments:14 (3 by maintainers)
Hi
I know this is closed but there is a better solution here loopback#1411 by @abovegradesoftware
Just needs a small addition from your FAQ, adding the CORS header like below
@anagrath : Actually I store the token in the cookies after user login, then I get them in the full request interceptor like this:
But clearly, @emresebat 's solution is better when you can modify your Loopback’s sources.