mirror of
https://github.com/Mottie/tablesorter.git
synced 2025-01-12 15:24:21 +00:00
Attempt to fix pager row count #455
This commit is contained in:
parent
474e446ef8
commit
224d7acb24
@ -263,6 +263,7 @@
|
|||||||
exception === 'abort' ? 'Ajax Request aborted' :
|
exception === 'abort' ? 'Ajax Request aborted' :
|
||||||
'Uncaught error: ' + xhr.statusText + ' [' + xhr.status + ']' );
|
'Uncaught error: ' + xhr.statusText + ' [' + xhr.status + ']' );
|
||||||
c.$tbodies.eq(0).empty();
|
c.$tbodies.eq(0).empty();
|
||||||
|
p.totalRows = 0;
|
||||||
} else {
|
} else {
|
||||||
// process ajax object
|
// process ajax object
|
||||||
if (!$.isArray(result)) {
|
if (!$.isArray(result)) {
|
||||||
@ -273,7 +274,7 @@
|
|||||||
} else {
|
} else {
|
||||||
// allow [ total, rows, headers ] or [ rows, total, headers ]
|
// allow [ total, rows, headers ] or [ rows, total, headers ]
|
||||||
t = isNaN(result[0]) && !isNaN(result[1]);
|
t = isNaN(result[0]) && !isNaN(result[1]);
|
||||||
//ensure a zero returned row count doesn't fail the logical ||
|
// ensure a zero returned row count doesn't fail the logical ||
|
||||||
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;
|
||||||
d = p.totalRows === 0 ? [""] : result[t ? 0 : 1] || []; // row data
|
d = p.totalRows === 0 ? [""] : result[t ? 0 : 1] || []; // row data
|
||||||
@ -345,6 +346,7 @@
|
|||||||
.trigger('pagerChange', p);
|
.trigger('pagerChange', p);
|
||||||
}
|
}
|
||||||
}]);
|
}]);
|
||||||
|
|
||||||
}
|
}
|
||||||
if (!p.initialized) {
|
if (!p.initialized) {
|
||||||
p.initialized = true;
|
p.initialized = true;
|
||||||
|
@ -150,7 +150,6 @@ tsp = ts.pager = {
|
|||||||
// page size selector
|
// page size selector
|
||||||
p.$size = p.$container.find(s.pageSize);
|
p.$size = p.$container.find(s.pageSize);
|
||||||
p.totalRows = c.$tbodies.eq(0).children().length;
|
p.totalRows = c.$tbodies.eq(0).children().length;
|
||||||
|
|
||||||
p.oldAjaxSuccess = p.oldAjaxSuccess || wo.pager_ajaxObject.success;
|
p.oldAjaxSuccess = p.oldAjaxSuccess || wo.pager_ajaxObject.success;
|
||||||
c.appender = tsp.appender;
|
c.appender = tsp.appender;
|
||||||
if (ts.filter && $.inArray('filter', c.widgets) >= 0) {
|
if (ts.filter && $.inArray('filter', c.widgets) >= 0) {
|
||||||
@ -453,6 +452,7 @@ tsp = ts.pager = {
|
|||||||
}
|
}
|
||||||
ts.showError(table, exception.message + ' (' + xhr.status + ')');
|
ts.showError(table, exception.message + ' (' + xhr.status + ')');
|
||||||
c.$tbodies.eq(0).empty();
|
c.$tbodies.eq(0).empty();
|
||||||
|
p.totalRows = 0;
|
||||||
} else {
|
} else {
|
||||||
// process ajax object
|
// process ajax object
|
||||||
if (!$.isArray(result)) {
|
if (!$.isArray(result)) {
|
||||||
@ -463,7 +463,7 @@ tsp = ts.pager = {
|
|||||||
} else {
|
} else {
|
||||||
// allow [ total, rows, headers ] or [ rows, total, headers ]
|
// allow [ total, rows, headers ] or [ rows, total, headers ]
|
||||||
t = isNaN(result[0]) && !isNaN(result[1]);
|
t = isNaN(result[0]) && !isNaN(result[1]);
|
||||||
//ensure a zero returned row count doesn't fail the logical ||
|
// ensure a zero returned row count doesn't fail the logical ||
|
||||||
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;
|
||||||
d = p.totalRows === 0 ? [""] : result[t ? 0 : 1] || []; // row data
|
d = p.totalRows === 0 ? [""] : result[t ? 0 : 1] || []; // row data
|
||||||
|
Loading…
Reference in New Issue
Block a user