Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Last child getting removed when only one row is displayed. #1710

Closed
diegodmendieta opened this issue Feb 11, 2020 · 2 comments
Closed

Last child getting removed when only one row is displayed. #1710

diegodmendieta opened this issue Feb 11, 2020 · 2 comments

Comments

@diegodmendieta
Copy link

diegodmendieta commented Feb 11, 2020

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 = "";
    }
  }
}
@Mottie
Copy link
Owner

Mottie commented Mar 3, 2020

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.

@Mottie
Copy link
Owner

Mottie commented Mar 3, 2020

New release is available.

I actually ended up changing last = -1. Please let me know if that doesn't work as expected.

@Mottie Mottie closed this as completed Mar 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants