Created
August 7, 2013 18:49
-
-
Save brihter/6177207 to your computer and use it in GitHub Desktop.
An ExtJS paging toolbar override that fixes the incorrect paging behaviour in an edge case. Compatible with ExtJS 4.2.1.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* A paging toolbar override that fixes the incorrect paging behaviour when navigating | |
* to a certain page (where page no. > 1), doing a remote load of data (i.e.: filtering | |
* data) and size of the remote data is less than store's defined pageSize. | |
* | |
* Compatible with ExtJS 4.2.1. | |
* | |
* @class Ext.toolbar.Paging | |
* @override | |
* @author Bostjan Rihter <[email protected]> | |
*/ | |
Ext.override(Ext.toolbar.Paging, { | |
getPageData: function () { | |
var store = this.store, | |
totalCount = store.getTotalCount(), | |
currentPage = store.currentPage, | |
pageCount = Math.ceil(totalCount / store.pageSize), | |
fromRecord = ((store.currentPage - 1) * store.pageSize) + 1, | |
toRecord = Math.min(store.currentPage * store.pageSize, totalCount); | |
//#region override | |
if (totalCount <= store.pageSize) { | |
currentPage = 1; | |
fromRecord = 1; | |
} | |
//#endregion | |
return { | |
total: totalCount, | |
currentPage: currentPage, | |
pageCount: pageCount, | |
fromRecord: fromRecord, | |
toRecord: toRecord | |
}; | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment