Pager stays on same page after update. Fixes #590

This commit is contained in:
Mottie 2014-04-23 15:47:54 -05:00
parent d1426ad1c5
commit 9cabd1797a
2 changed files with 8 additions and 5 deletions

View File

@ -497,7 +497,6 @@
} }
ts.processTbody(table, $tb, false); ts.processTbody(table, $tb, false);
} }
updatePageDisplay(table, p); updatePageDisplay(table, p);
if ( !p.isDisabled ) { fixHeight(table, p); } if ( !p.isDisabled ) { fixHeight(table, p); }
$t.trigger('applyWidgets'); $t.trigger('applyWidgets');
@ -695,15 +694,17 @@
.unbind('filterStart filterEnd sortEnd disable enable destroy update updateRows updateAll addRows pageSize '.split(' ').join('.pager ')) .unbind('filterStart filterEnd sortEnd disable enable destroy update updateRows updateAll addRows pageSize '.split(' ').join('.pager '))
.bind('filterStart.pager', function(e, filters) { .bind('filterStart.pager', function(e, filters) {
p.currentFilters = filters; p.currentFilters = filters;
if (p.pageReset !== false) { // don't change page is filters are the same (pager updating, etc)
if (p.pageReset !== false && (c.lastCombinedFilter || '') !== (filters || []).join('')) {
p.page = p.pageReset; // fixes #456 & #565 p.page = p.pageReset; // fixes #456 & #565
} }
}) })
// update pager after filter widget completes // update pager after filter widget completes
.bind('filterEnd.pager sortEnd.pager', function() { .bind('filterEnd.pager sortEnd.pager', function() {
if (p.initialized) { if (p.initialized) {
moveToPage(table, p, false); // update page display first, so we update p.filteredPages
updatePageDisplay(table, p, false); updatePageDisplay(table, p, false);
moveToPage(table, p, false);
fixHeight(table, p); fixHeight(table, p);
} }
}) })

View File

@ -214,15 +214,17 @@ tsp = ts.pager = {
.unbind('filterStart filterEnd sortEnd disable enable destroy update updateRows updateAll addRows pageSize '.split(' ').join('.pager ')) .unbind('filterStart filterEnd sortEnd disable enable destroy update updateRows updateAll addRows pageSize '.split(' ').join('.pager '))
.bind('filterStart.pager', function(e, filters) { .bind('filterStart.pager', function(e, filters) {
p.currentFilters = filters; p.currentFilters = filters;
if (wo.pager_pageReset !== false) { // don't change page is filters are the same (pager updating, etc)
if (wo.pager_pageReset !== false && (c.lastCombinedFilter || '') !== (filters || []).join('')) {
p.page = wo.pager_pageReset; // fixes #456 & #565 p.page = wo.pager_pageReset; // fixes #456 & #565
} }
}) })
// update pager after filter widget completes // update pager after filter widget completes
.bind('filterEnd.pager sortEnd.pager', function() { .bind('filterEnd.pager sortEnd.pager', function() {
if (p.initialized) { if (p.initialized) {
tsp.moveToPage(table, p, false); // update page display first, so we update p.filteredPages
tsp.updatePageDisplay(table, c, false); tsp.updatePageDisplay(table, c, false);
tsp.moveToPage(table, p, false);
tsp.fixHeight(table, c); tsp.fixHeight(table, c);
} }
}) })