Filter widget: fix filteredRows count & cleanup

This commit is contained in:
Mottie 2014-04-23 16:09:26 -05:00
parent 9cabd1797a
commit c7607401b8
3 changed files with 12 additions and 4 deletions

View File

@ -142,7 +142,7 @@
p.filteredPages = p.totalPages;
if (f) {
$.each(c.cache[0].normalized, function(i, el) {
p.filteredRows += /(filtered|removeme|tablesorter-childRow)/.test(el[c.columns].$row[0].className) ? 0 : 1;
p.filteredRows += p.regexRows.test(el[c.columns].$row[0].className) ? 0 : 1;
});
p.filteredPages = Math.ceil( p.filteredRows / sz ) || 0;
}
@ -668,6 +668,7 @@
var t, ctrls, fxn,
table = this,
c = table.config,
wo = c.widgetOptions,
p = c.pager = $.extend( true, {}, $.tablesorterPager.defaults, settings ),
$t = c.$table,
// added in case the pager is reinitialized after being destroyed.
@ -690,6 +691,9 @@
$.data(table, 'pagerLastSize', p.size);
}
// skipped rows
p.regexRows = new RegExp('(' + (wo.filter_filteredRow || 'filtered') + '|' + c.selectorRemove.substring(1) + '|' + c.cssChildRow + ')');
$t
.unbind('filterStart filterEnd sortEnd disable enable destroy update updateRows updateAll addRows pageSize '.split(' ').join('.pager '))
.bind('filterStart.pager', function(e, filters) {

View File

@ -37,7 +37,7 @@
// setting this to false, only hides the non-visible rows; needed if you plan to add/remove rows with the pager enabled.
removeRows: false,
// go to page selector - select dropdown that sets the current page
cssGoto: '.gotoPage'
cssGoto: '.gotoPage'
};
// Initialize tablesorter

View File

@ -168,6 +168,10 @@ tsp = ts.pager = {
p.size = ( isNaN(t.size) ? p.size : t.size ) || 10;
$.data(table, 'pagerLastSize', p.size);
}
// skipped rows
p.regexRows = new RegExp('(' + (wo.filter_filteredRow || 'filtered') + '|' + c.selectorRemove.substring(1) + '|' + c.cssChildRow + ')');
// clear initialized flag
p.initialized = false;
// before initialization event
@ -329,7 +333,7 @@ tsp = ts.pager = {
f = c.$table.hasClass('hasFilters') && !wo.pager_ajaxUrl,
t = [],
sz = p.size || 10; // don't allow dividing by zero
t = [ c.widgetOptions && c.widgetOptions.filter_filteredRow || 'filtered', c.selectorRemove ];
t = [ wo && wo.filter_filteredRow || 'filtered', c.selectorRemove ];
if (wo.pager_countChildRows) { t.push(c.cssChildRow); }
regex = new RegExp( '(' + t.join('|') + ')' );
p.$size.add(p.$goto).removeClass(wo.pager_css.disabled).removeAttr('disabled').attr('aria-disabled', 'false');
@ -338,7 +342,7 @@ tsp = ts.pager = {
p.filteredPages = p.totalPages;
if (f) {
$.each(c.cache[0].normalized, function(i, el) {
p.filteredRows += /(filtered|removeme|tablesorter-childRow)/.test(el[c.columns].$row[0].className) ? 0 : 1;
p.filteredRows += p.regexRows.test(el[c.columns].$row[0].className) ? 0 : 1;
});
p.filteredPages = Math.ceil( p.filteredRows / sz ) || 0;
}