Pager: current filters now updating properly. See #757

This commit is contained in:
Mottie 2014-11-03 08:05:22 -06:00
parent fcde1041be
commit a20b37bfd0
2 changed files with 7 additions and 4 deletions

View File

@ -501,6 +501,7 @@
counter = ++p.ajaxCounter; counter = ++p.ajaxCounter;
p.last.ajaxUrl = url; // remember processed url
p.ajaxObject.url = url; // from the ajaxUrl option and modified by customAjaxUrl p.ajaxObject.url = url; // from the ajaxUrl option and modified by customAjaxUrl
p.ajaxObject.success = function(data, status, jqxhr) { p.ajaxObject.success = function(data, status, jqxhr) {
// Refuse to process old ajax commands that were overwritten by new ones - see #443 // Refuse to process old ajax commands that were overwritten by new ones - see #443
@ -831,14 +832,15 @@
$t $t
.unbind('filterInit filterStart filterEnd sortEnd disable enable destroy updateComplete pageSize pageSet '.split(' ').join('.pager ')) .unbind('filterInit filterStart filterEnd sortEnd disable enable destroy updateComplete pageSize pageSet '.split(' ').join('.pager '))
.bind('filterInit.pager filterStart.pager', function() { .bind('filterInit.pager filterStart.pager', function() {
p.currentFilters = $t.data('lastSearch'); p.currentFilters = c.$table.data('lastSearch');
// don't change page is filters are the same (pager updating, etc) // don't change page if filters are the same (pager updating, etc)
if (p.pageReset !== false && (c.lastCombinedFilter || '') !== (p.currentFilters || []).join('')) { if (p.pageReset !== false && (c.lastCombinedFilter || '') !== (p.currentFilters || []).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(e) { .bind('filterEnd.pager sortEnd.pager', function(e) {
p.currentFilters = c.$table.data('lastSearch');
if (p.initialized || p.initializing) { if (p.initialized || p.initializing) {
if (c.delayInit && c.rowsCopy && c.rowsCopy.length === 0) { if (c.delayInit && c.rowsCopy && c.rowsCopy.length === 0) {
// make sure we have a copy of all table rows once the cache has been built // make sure we have a copy of all table rows once the cache has been built

View File

@ -223,20 +223,20 @@ tsp = ts.pager = {
.off('filterInit filterStart filterEnd sortEnd disable enable destroy updateComplete pageSize pageSet '.split(' ').join('.pager ')) .off('filterInit filterStart filterEnd sortEnd disable enable destroy updateComplete pageSize pageSet '.split(' ').join('.pager '))
.on('filterInit.pager filterStart.pager', function() { .on('filterInit.pager filterStart.pager', function() {
p.currentFilters = c.$table.data('lastSearch'); p.currentFilters = c.$table.data('lastSearch');
// don't change page is filters are the same (pager updating, etc) // don't change page if filters are the same (pager updating, etc)
if (wo.pager_pageReset !== false && (c.lastCombinedFilter || '') !== (p.currentFilters || []).join('')) { if (wo.pager_pageReset !== false && (c.lastCombinedFilter || '') !== (p.currentFilters || []).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
.on('filterEnd.pager sortEnd.pager', function() { .on('filterEnd.pager sortEnd.pager', function() {
p.currentFilters = c.$table.data('lastSearch');
if (p.initialized || p.initializing) { if (p.initialized || p.initializing) {
if (c.delayInit && c.rowsCopy && c.rowsCopy.length === 0) { if (c.delayInit && c.rowsCopy && c.rowsCopy.length === 0) {
// make sure we have a copy of all table rows once the cache has been built // make sure we have a copy of all table rows once the cache has been built
tsp.updateCache(table); tsp.updateCache(table);
} }
// tsp.moveToPage(table, p, false); <-- called when applyWidgets is triggered // tsp.moveToPage(table, p, false); <-- called when applyWidgets is triggered
c.pager.last.page = -1;
c.$table.trigger('applyWidgets'); c.$table.trigger('applyWidgets');
tsp.updatePageDisplay(table, c, false); tsp.updatePageDisplay(table, c, false);
} }
@ -715,6 +715,7 @@ tsp = ts.pager = {
$doc.off('ajaxError.pager'); $doc.off('ajaxError.pager');
}); });
counter = ++p.ajaxCounter; counter = ++p.ajaxCounter;
p.last.ajaxUrl = url; // remember processed url
p.ajaxObject.url = url; // from the ajaxUrl option and modified by customAjaxUrl p.ajaxObject.url = url; // from the ajaxUrl option and modified by customAjaxUrl
p.ajaxObject.success = function(data, status, jqxhr) { p.ajaxObject.success = function(data, status, jqxhr) {
// Refuse to process old ajax commands that were overwritten by new ones - see #443 // Refuse to process old ajax commands that were overwritten by new ones - see #443