From 638d070f3ad3c1ead30c060a7fb5a440546f994e Mon Sep 17 00:00:00 2001 From: Mottie Date: Fri, 9 Jan 2015 07:22:25 -0600 Subject: [PATCH] Pager: filteredRows now properly calculated when first tbody set with cssInfoBlock class --- addons/pager/jquery.tablesorter.pager.js | 10 +++++++--- js/widgets/widget-pager.js | 10 +++++++--- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/addons/pager/jquery.tablesorter.pager.js b/addons/pager/jquery.tablesorter.pager.js index d1a56fbe..df3b15bd 100644 --- a/addons/pager/jquery.tablesorter.pager.js +++ b/addons/pager/jquery.tablesorter.pager.js @@ -132,15 +132,18 @@ }, calcFilters = function(table, p) { - var c = table.config, + var tbodyIndex, + c = table.config, hasFilters = c.$table.hasClass('hasFilters'); if (hasFilters && !p.ajaxUrl) { if ($.isEmptyObject(c.cache)) { // delayInit: true so nothing is in the cache p.filteredRows = p.totalRows = c.$tbodies.eq(0).children('tr').not( p.countChildRows ? '' : '.' + c.cssChildRow ).length; } else { + // just in case the pager tbody isn't the first tbody + tbodyIndex = c.$table.children('tbody').index( c.$tbodies.eq(0) ); p.filteredRows = 0; - $.each(c.cache[0].normalized, function(i, el) { + $.each(c.cache[tbodyIndex].normalized, function(i, el) { p.filteredRows += p.regexRows.test(el[c.columns].$row[0].className) ? 0 : 1; }); } @@ -644,7 +647,8 @@ c.$table.trigger('updateCache', [ function(){ var i, rows = [], - n = table.config.cache[0].normalized; + tbodyIndex = c.$table.children('tbody').index( c.$tbodies.eq(0) ), + n = table.config.cache[tbodyIndex].normalized; p.totalRows = n.length; for (i = 0; i < p.totalRows; i++) { rows.push(n[i][c.columns].$row); diff --git a/js/widgets/widget-pager.js b/js/widgets/widget-pager.js index 7f0e025f..1bb1062e 100644 --- a/js/widgets/widget-pager.js +++ b/js/widgets/widget-pager.js @@ -356,7 +356,8 @@ tsp = ts.pager = { }, calcFilters: function(table, c) { - var wo = c.widgetOptions, + var tbodyIndex, + wo = c.widgetOptions, p = c.pager, hasFilters = c.$table.hasClass('hasFilters'); if (hasFilters && !wo.pager_ajaxUrl) { @@ -364,8 +365,10 @@ tsp = ts.pager = { // delayInit: true so nothing is in the cache p.filteredRows = p.totalRows = c.$tbodies.eq(0).children('tr').not( wo.pager_countChildRows ? '' : '.' + c.cssChildRow ).length; } else { + // just in case the pager tbody isn't the first tbody + tbodyIndex = c.$table.children('tbody').index( c.$tbodies.eq(0) ); p.filteredRows = 0; - $.each(c.cache[0].normalized, function(i, el) { + $.each(c.cache[tbodyIndex].normalized, function(i, el) { p.filteredRows += p.regexRows.test(el[c.columns].$row[0].className) ? 0 : 1; }); } @@ -871,7 +874,8 @@ tsp = ts.pager = { if ( !$.isEmptyObject(table.config.cache) ) { var i, rows = [], - n = table.config.cache[0].normalized; + tbodyIndex = c.$table.children('tbody').index( c.$tbodies.eq(0) ), + n = table.config.cache[tbodyIndex].normalized; p.totalRows = n.length; for (i = 0; i < p.totalRows; i++) { rows.push(n[i][c.columns].$row);