Pager: update c.filteredRows when using ajax. Fixes #670

This commit is contained in:
Mottie 2014-07-03 09:32:27 -05:00
parent 7e36b9553b
commit 21492fe960
2 changed files with 6 additions and 4 deletions

View File

@ -146,6 +146,7 @@
} else if (!f) { } else if (!f) {
p.filteredRows = p.totalRows; p.filteredRows = p.totalRows;
} }
c.filteredRows = p.filteredRows;
p.filteredPages = Math.ceil( p.filteredRows / sz ) || 0; p.filteredPages = Math.ceil( p.filteredRows / sz ) || 0;
if ( Math.min( p.totalPages, p.filteredPages ) >= 0 ) { if ( Math.min( p.totalPages, p.filteredPages ) >= 0 ) {
t = (p.size * p.page > p.filteredRows); t = (p.size * p.page > p.filteredRows);
@ -297,7 +298,7 @@
if (!$.isArray(result)) { if (!$.isArray(result)) {
p.ajaxData = result; p.ajaxData = result;
p.totalRows = result.total; 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; th = result.headers;
d = result.rows; d = result.rows;
} else { } else {
@ -307,7 +308,7 @@
rr_count = result[t ? 1 : 0]; rr_count = result[t ? 1 : 0];
p.totalRows = isNaN(rr_count) ? p.totalRows || 0 : rr_count; p.totalRows = isNaN(rr_count) ? p.totalRows || 0 : rr_count;
// can't set filtered rows when returning an array // 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 d = p.totalRows === 0 ? [""] : result[t ? 0 : 1] || []; // row data
th = result[2]; // headers th = result[2]; // headers
} }

View File

@ -351,6 +351,7 @@ tsp = ts.pager = {
} else if (!f) { } else if (!f) {
p.filteredRows = p.totalRows; p.filteredRows = p.totalRows;
} }
c.filteredRows = p.filteredRows;
p.filteredPages = Math.ceil( p.filteredRows / sz ) || 0; p.filteredPages = Math.ceil( p.filteredRows / sz ) || 0;
if ( Math.min( p.totalPages, p.filteredPages ) >= 0 ) { if ( Math.min( p.totalPages, p.filteredPages ) >= 0 ) {
t = (p.size * p.page > p.filteredRows); t = (p.size * p.page > p.filteredRows);
@ -499,7 +500,7 @@ tsp = ts.pager = {
if (!$.isArray(result)) { if (!$.isArray(result)) {
p.ajaxData = result; p.ajaxData = result;
p.totalRows = result.total; 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; th = result.headers;
d = result.rows; d = result.rows;
} else { } else {
@ -509,7 +510,7 @@ tsp = ts.pager = {
rr_count = result[t ? 1 : 0]; rr_count = result[t ? 1 : 0];
p.totalRows = isNaN(rr_count) ? p.totalRows || 0 : rr_count; p.totalRows = isNaN(rr_count) ? p.totalRows || 0 : rr_count;
// can't set filtered rows when returning an array // 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 d = p.totalRows === 0 ? [""] : result[t ? 0 : 1] || []; // row data
th = result[2]; // headers th = result[2]; // headers
} }