Skip to content
This repository has been archived by the owner on May 17, 2018. It is now read-only.

Uncaught RangeError: currentPage must be firstPage <= currentPage >= totalPages if 0-based. Got 7. #158

Closed
hoangpx opened this issue Apr 9, 2014 · 10 comments
Labels

Comments

@hoangpx
Copy link

hoangpx commented Apr 9, 2014

My total_pages = 1 and my total_entries = 63. I'm displaying page with 100 items and change page size to 10. Then it throw this error.
This is my configuration :
state: {
pageSize: 20,
firstPage: 0

    },
    queryParams: {
        currentPage: "offset",
        pageSize: "limit",
        sortKey: "sortBy",
        totalRecords: "total_entries",
        order: "sortOrder"
    },
@wyuenho
Copy link
Member

wyuenho commented Apr 9, 2014

If you are displaying a page with 100 items then why do you have a pageSize of 20? How did you change the page size?

@hoangpx
Copy link
Author

hoangpx commented Apr 9, 2014

My initial page size is 20. I have options to choose page size [10, 20 ,50, 100]. First I changed page size to 100. It's ok. After that I changed to 10. It throw that error.
This is how I change page size :
this.collection.setPageSize(pageSize);
Thanks for your quick response.

@wyuenho
Copy link
Member

wyuenho commented Apr 9, 2014

I can't reproduce it from the backgrid examples. Which version of backbone and pageable are you using?

@hoangpx
Copy link
Author

hoangpx commented Apr 9, 2014

Backbone.js 1.0.0 and backbone-pageable 1.4.5

@wyuenho
Copy link
Member

wyuenho commented Apr 9, 2014

Can you please upgrade to backbone >= 1.1.0 and try again please? pageable doesn't work with 1.0.0.

@hoangpx
Copy link
Author

hoangpx commented Apr 9, 2014

OK, I changed bb to 1.1.2 and it's still happen.

@hoangpx
Copy link
Author

hoangpx commented Apr 9, 2014

This is state before I changed page size
screen shot 2014-04-09 at 9 04 35 pm

@wyuenho
Copy link
Member

wyuenho commented Apr 9, 2014

Ah ok. Looks like this only happens when firstPage is 0 and when you are shrinking the page size

@wyuenho wyuenho added the bug label Apr 9, 2014
@wyuenho
Copy link
Member

wyuenho commented Apr 9, 2014

For now you can use setPageSize(10, {first: true}) to get around this. This is most likely what you'll want to do anyway.

@hoangpx
Copy link
Author

hoangpx commented Apr 9, 2014

It worked. Thanks a million.

@hoangpx hoangpx closed this as completed Apr 9, 2014
@wyuenho wyuenho reopened this Apr 9, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants