Pager: prevent adding row if JSON totalrows = 0

See http://stackoverflow.com/q/30875583/145346
This commit is contained in:
Mottie 2015-06-16 20:37:57 -05:00
parent 66f1cf5b4f
commit d36184a1d4
4 changed files with 8 additions and 6 deletions

View File

@ -408,7 +408,7 @@
c.totalRows = p.totalRows = result.total;
c.filteredRows = p.filteredRows = typeof result.filteredRows !== 'undefined' ? result.filteredRows : result.total;
th = result.headers;
d = result.rows;
d = result.rows || [];
} else {
// allow [ total, rows, headers ] or [ rows, total, headers ]
t = isNaN(result[0]) && !isNaN(result[1]);
@ -417,7 +417,8 @@
p.totalRows = isNaN(rr_count) ? p.totalRows || 0 : rr_count;
// can't set filtered rows when returning an array
c.totalRows = c.filteredRows = p.filteredRows = p.totalRows;
d = p.totalRows === 0 ? [""] : result[t ? 0 : 1] || []; // row data
// set row data to empty array if nothing found - see http://stackoverflow.com/q/30875583/145346
d = p.totalRows === 0 ? [] : result[t ? 0 : 1] || []; // row data
th = result[2]; // headers
}
l = d && d.length;

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -661,7 +661,7 @@ tsp = ts.pager = {
c.totalRows = p.totalRows = result.total;
c.filteredRows = p.filteredRows = typeof result.filteredRows !== 'undefined' ? result.filteredRows : result.total;
th = result.headers;
d = result.rows;
d = result.rows || [];
} else {
// allow [ total, rows, headers ] or [ rows, total, headers ]
t = isNaN(result[0]) && !isNaN(result[1]);
@ -670,7 +670,8 @@ tsp = ts.pager = {
p.totalRows = isNaN(rr_count) ? p.totalRows || 0 : rr_count;
// can't set filtered rows when returning an array
c.totalRows = c.filteredRows = p.filteredRows = p.totalRows;
d = p.totalRows === 0 ? [""] : result[t ? 0 : 1] || []; // row data
// set row data to empty array if nothing found - see http://stackoverflow.com/q/30875583/145346
d = p.totalRows === 0 ? [] : result[t ? 0 : 1] || []; // row data
th = result[2]; // headers
}
l = d && d.length;