countVisibleRows() returns wrong values in the afterFilter hook

Tags: #<Tag:0x00007f13606672c0> #<Tag:0x00007f1360667180>

Our app is using the filters plugin. Inside the afterFilter hook, I want to get the number of visible rows in the table, but the values returned are wrong and indeterministic.

After I filter the rows, often the number of rows before filtering is returned, when I filter to 0 rows, then the new value is returned - 0. Sometimes I can obtain the correct new number of rows, but it’s very rare.
It seems like a race condition to me.

The methods I tried using: countVisibleRows(), countRenderedRows().

Am I doing something wrong?

Hi @damian.garbala

Please check if that demo is useful https://jsfiddle.net/buj2fd9y/

I’ve added

  • a dataset that is left after the filtering
  • number of rows that are left
  • indexes of rows that are left

If I’m missing anything please let me know,

Thanks for your reply! It seems that countRows works correctly for my use case.

But still, the race condition issue still remains in the mentioned methods.

The countVisibleRows applies only for rows that are fully visible in the viewport, if any row is cut or visible only on scroll it won’t be counted. The same goes for countRenderedRows. And countRows() counts all of the rows, regardless of scroll and viewport.