From 21492fe9605e9610eb61eaffe631602162b49936 Mon Sep 17 00:00:00 2001 From: Mottie Date: Thu, 3 Jul 2014 09:32:27 -0500 Subject: [PATCH] Pager: update c.filteredRows when using ajax. Fixes #670 --- addons/pager/jquery.tablesorter.pager.js | 5 +++-- js/widgets/widget-pager.js | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/addons/pager/jquery.tablesorter.pager.js b/addons/pager/jquery.tablesorter.pager.js index 0eda3f95..54d98b65 100644 --- a/addons/pager/jquery.tablesorter.pager.js +++ b/addons/pager/jquery.tablesorter.pager.js @@ -146,6 +146,7 @@ } else if (!f) { p.filteredRows = p.totalRows; } + c.filteredRows = p.filteredRows; p.filteredPages = Math.ceil( p.filteredRows / sz ) || 0; if ( Math.min( p.totalPages, p.filteredPages ) >= 0 ) { t = (p.size * p.page > p.filteredRows); @@ -297,7 +298,7 @@ if (!$.isArray(result)) { p.ajaxData = result; p.totalRows = result.total; - p.filteredRows = typeof result.filteredRows !== 'undefined' ? result.filteredRows : result.total; + c.filteredRows = p.filteredRows = typeof result.filteredRows !== 'undefined' ? result.filteredRows : result.total; th = result.headers; d = result.rows; } else { @@ -307,7 +308,7 @@ rr_count = result[t ? 1 : 0]; p.totalRows = isNaN(rr_count) ? p.totalRows || 0 : rr_count; // can't set filtered rows when returning an array - p.filteredRows = p.totalRows; + c.filteredRows = p.filteredRows = p.totalRows; d = p.totalRows === 0 ? [""] : result[t ? 0 : 1] || []; // row data th = result[2]; // headers } diff --git a/js/widgets/widget-pager.js b/js/widgets/widget-pager.js index dec60085..4b838db6 100644 --- a/js/widgets/widget-pager.js +++ b/js/widgets/widget-pager.js @@ -351,6 +351,7 @@ tsp = ts.pager = { } else if (!f) { p.filteredRows = p.totalRows; } + c.filteredRows = p.filteredRows; p.filteredPages = Math.ceil( p.filteredRows / sz ) || 0; if ( Math.min( p.totalPages, p.filteredPages ) >= 0 ) { t = (p.size * p.page > p.filteredRows); @@ -499,7 +500,7 @@ tsp = ts.pager = { if (!$.isArray(result)) { p.ajaxData = result; p.totalRows = result.total; - p.filteredRows = typeof result.filteredRows !== 'undefined' ? result.filteredRows : result.total; + c.filteredRows = p.filteredRows = typeof result.filteredRows !== 'undefined' ? result.filteredRows : result.total; th = result.headers; d = result.rows; } else { @@ -509,7 +510,7 @@ tsp = ts.pager = { rr_count = result[t ? 1 : 0]; p.totalRows = isNaN(rr_count) ? p.totalRows || 0 : rr_count; // can't set filtered rows when returning an array - p.filteredRows = p.totalRows; + c.filteredRows = p.filteredRows = p.totalRows; d = p.totalRows === 0 ? [""] : result[t ? 0 : 1] || []; // row data th = result[2]; // headers }