Last child getting removed when only one row is displayed.
diegodmendieta opened this issue · comments
The last child of a row is getting removed when only one row and one child is available.
I fixed this changing lastIndex to -1, so that when it runs through the first parent it will be set to 0:
if (!p.ajaxUrl) {
var i,
lastIndex = -1,
//change from =0 to =-1
c = table.config,
rows = c.$tbodies.eq(0).children("tr"),
l = rows.length,
sz = p.size === "all" ? p.totalRows : p.size,
s = p.page * sz,
e = s + sz,
last = 0, // for cache indexing
j = 0; // size counter
p.cacheIndex = [];
for (i = 0; i < l; i++) {
if (!p.regexFiltered.test(rows[i].className)) {
if (j === s && rows[i].className.match(c.cssChildRow)) {
// hide child rows @ start of pager (if already visible)
rows[i].style.display = "none";
} else {
rows[i].style.display = j >= s && j < e ? "" : "none";
if (last !== j && j >= s && j < e) {
p.cacheIndex[p.cacheIndex.length] = i;
last = j;
}
// don't count child rows
j +=
rows[i].className.match(
c.cssChildRow + "|" + c.selectorRemove.slice(1)
) && !p.countChildRows
? 0
: 1;
if (
j === e &&
rows[i].style.display !== "none" &&
rows[i].className.match(ts.css.cssHasChild)
) {
lastIndex = i;
}
}
}
}
// add any attached child rows to last row of pager. Fixes part of issue #396
if (lastIndex >= 0 && rows[lastIndex].className.match(ts.css.cssHasChild)) {
while (++lastIndex < l && rows[lastIndex].className.match(c.cssChildRow)) {
rows[lastIndex].style.display = "";
}
}
}
Hi @diegodmendieta!
Sorry for the delay! This is probably related to the issue brought up in #1714. I'll get this fixed in the latest version.
New release is available.
I actually ended up changing last = -1
. Please let me know if that doesn't work as expected.