Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to reset pagination when last page < current page #3987

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/js/modules/Page/Page.js
Expand Up @@ -38,6 +38,7 @@ class Page extends Module{
// this.registerTableOption("paginationDataSent", {}); //pagination data sent to the server
// this.registerTableOption("paginationDataReceived", {}); //pagination data received from the server
this.registerTableOption("paginationAddRow", "page"); //add rows on table or page
this.registerTableOption("paginationOutOfRange", false); //reset the current page when the last page < this.page, values: false|function|any value accepted by setPage()

this.registerTableOption("progressiveLoad", false); //progressive loading
this.registerTableOption("progressiveLoadDelay", 0); //delay between requests
Expand Down Expand Up @@ -844,6 +845,21 @@ class Page extends Module{

return false;
}else{

if(this.page > this.max){
console.warn( "Remote Pagination Error - Server returned last page value lower than the current page" );

const paginationOutOfRange = this.options('paginationOutOfRange');

if(paginationOutOfRange){
return this.setPage(
typeof paginationOutOfRange === 'function' ?
paginationOutOfRange.call(this, this.page, this.max) :
paginationOutOfRange
);
}
}

// left = this.table.rowManager.scrollLeft;
this.dispatchExternal("pageLoaded", this.getPage());
// this.table.rowManager.scrollHorizontal(left);
Expand Down