mirror of
https://github.com/Mottie/tablesorter.git
synced 2024-10-08 13:44:18 +00:00
Remove rows from table when using pager ajax #411
This commit is contained in:
parent
e6696b0a1e
commit
3b333d0d9b
@ -122,7 +122,8 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
/* debuging utils */
|
/* debuging utils */
|
||||||
function log(s) {
|
function log() {
|
||||||
|
var s = arguments.length > 1 ? Array.prototype.slice.call(arguments) : arguments[0];
|
||||||
if (typeof console !== "undefined" && typeof console.log !== "undefined") {
|
if (typeof console !== "undefined" && typeof console.log !== "undefined") {
|
||||||
console.log(s);
|
console.log(s);
|
||||||
} else {
|
} else {
|
||||||
@ -201,9 +202,12 @@
|
|||||||
var c = table.config,
|
var c = table.config,
|
||||||
// update table bodies in case we start with an empty table
|
// update table bodies in case we start with an empty table
|
||||||
tb = c.$tbodies = c.$table.children('tbody:not(.' + c.cssInfoBlock + ')'),
|
tb = c.$tbodies = c.$table.children('tbody:not(.' + c.cssInfoBlock + ')'),
|
||||||
rows, list, l, i, h, ch, p, parsersDebug = "";
|
rows, list, l, i, h, ch, p, time, parsersDebug = "";
|
||||||
if ( tb.length === 0) {
|
if ( tb.length === 0) {
|
||||||
return c.debug ? log('*Empty table!* Not building a parser cache') : '';
|
return c.debug ? log('*Empty table!* Not building a parser cache') : '';
|
||||||
|
} else if (c.debug) {
|
||||||
|
time = new Date();
|
||||||
|
log('Detecting parsers for each column');
|
||||||
}
|
}
|
||||||
rows = tb[0].rows;
|
rows = tb[0].rows;
|
||||||
if (rows[0]) {
|
if (rows[0]) {
|
||||||
@ -233,6 +237,7 @@
|
|||||||
}
|
}
|
||||||
if (c.debug) {
|
if (c.debug) {
|
||||||
log(parsersDebug);
|
log(parsersDebug);
|
||||||
|
benchmark("Completed detecting parsers", time);
|
||||||
}
|
}
|
||||||
c.parsers = list;
|
c.parsers = list;
|
||||||
}
|
}
|
||||||
@ -301,6 +306,7 @@
|
|||||||
// init flag (true) used by pager plugin to prevent widget application
|
// init flag (true) used by pager plugin to prevent widget application
|
||||||
function appendToTable(table, init) {
|
function appendToTable(table, init) {
|
||||||
var c = table.config,
|
var c = table.config,
|
||||||
|
wo = c.widgetOptions,
|
||||||
b = table.tBodies,
|
b = table.tBodies,
|
||||||
rows = [],
|
rows = [],
|
||||||
c2 = c.cache,
|
c2 = c.cache,
|
||||||
@ -322,8 +328,8 @@
|
|||||||
for (i = 0; i < totalRows; i++) {
|
for (i = 0; i < totalRows; i++) {
|
||||||
pos = n[i][checkCell];
|
pos = n[i][checkCell];
|
||||||
rows.push(r[pos]);
|
rows.push(r[pos]);
|
||||||
// removeRows used by the pager plugin
|
// removeRows used by the pager plugin; don't render if using ajax - fixes #411
|
||||||
if (!c.appender || !c.removeRows) {
|
if (!c.appender || (c.pager && (!c.pager.removeRows || !wo.pager_removeRows) && !c.pager.ajax)) {
|
||||||
l = r[pos].length;
|
l = r[pos].length;
|
||||||
for (j = 0; j < l; j++) {
|
for (j = 0; j < l; j++) {
|
||||||
$tb.append(r[pos][j]);
|
$tb.append(r[pos][j]);
|
||||||
@ -340,8 +346,8 @@
|
|||||||
if (c.debug) {
|
if (c.debug) {
|
||||||
benchmark("Rebuilt table", appendTime);
|
benchmark("Rebuilt table", appendTime);
|
||||||
}
|
}
|
||||||
// apply table widgets
|
// apply table widgets; but not before ajax completes
|
||||||
if (!init) { ts.applyWidget(table); }
|
if (!init && !c.appender) { ts.applyWidget(table); }
|
||||||
// trigger sortend
|
// trigger sortend
|
||||||
$(table).trigger("sortEnd", table);
|
$(table).trigger("sortEnd", table);
|
||||||
$(table).trigger("updateComplete", table);
|
$(table).trigger("updateComplete", table);
|
||||||
@ -517,7 +523,7 @@
|
|||||||
// ensure all sortList values are numeric - fixes #127
|
// ensure all sortList values are numeric - fixes #127
|
||||||
s = [ parseInt(v[0], 10), parseInt(v[1], 10) ];
|
s = [ parseInt(v[0], 10), parseInt(v[1], 10) ];
|
||||||
// make sure header exists
|
// make sure header exists
|
||||||
o = c.headerList[s[0]];
|
o = c.$headers[s[0]];
|
||||||
if (o) { // prevents error if sorton array is wrong
|
if (o) { // prevents error if sorton array is wrong
|
||||||
c.sortList.push(s);
|
c.sortList.push(s);
|
||||||
t = $.inArray(s[1], o.order); // fixes issue #167
|
t = $.inArray(s[1], o.order); // fixes issue #167
|
||||||
@ -584,12 +590,13 @@
|
|||||||
}
|
}
|
||||||
// the user has clicked on an already sorted column
|
// the user has clicked on an already sorted column
|
||||||
if (ts.isValueInArray(i, c.sortList)) {
|
if (ts.isValueInArray(i, c.sortList)) {
|
||||||
// reverse the sorting direction for all tables
|
// reverse the sorting direction
|
||||||
for (j = 0; j < c.sortList.length; j++) {
|
for (j = 0; j < c.sortList.length; j++) {
|
||||||
s = c.sortList[j];
|
s = c.sortList[j];
|
||||||
o = c.headerList[s[0]];
|
o = c.$headers[s[0]];
|
||||||
if (s[0] === i) {
|
if (s[0] === i) {
|
||||||
s[1] = o.order[o.count];
|
// o.count seems to be incorrect when compared to cell.count
|
||||||
|
s[1] = o.order[cell.count];
|
||||||
if (s[1] === 2) {
|
if (s[1] === 2) {
|
||||||
c.sortList.splice(j,1);
|
c.sortList.splice(j,1);
|
||||||
o.count = -1;
|
o.count = -1;
|
||||||
|
Loading…
Reference in New Issue
Block a user