[DT 1.9.4] How to get the subset of rows currently being displayed to the user?
[DT 1.9.4] How to get the subset of rows currently being displayed to the user?

Suppose I have 1000 rows, but showing only 10 per page. Now how can I get the 10 rows that the user is currently seeing? I see that I can use _ (underscore) method like this: dataTable._('tr', {"filter":"applied"});
, however that works only if I am filtering (using the search box), otherwise it returns all the 1000 rows. Without doing filter, is there any way to get the set of rows that are currently being rendered on current page?
Thanks a lot.
This question has an accepted answers - jump to answer
Answers
Should be able to use the
selector-modifier
, Such as..Heres a quick example, which just gets the indexes of the visible rows.. (Click the button at the top, then change the length, or filter, then click it again)
Thanks a lot jLinux, I was able to do this:
I can even combine the modifiers!!
Very nice :)
Ok, so I got some update. The above method works "all" the time except in "page.dt" handler (which fires during page change event). The following gives me empty:
On the other hand, this returns full set of data (given no filter is applied)
So clearly, "page":"current" does not work during page change. Any ideas how can I achieve that?
I cant seem to replicate the issue..
http://live.datatables.net/jofazibi/5/edit?js,output
Can you update that to replicate what you're seeing? If you cant, then im sorry, cant do much to help
Thanks jLinux for the demo, may be its working for you because you are using the latest version of datatable. I am using 1.9.4, and its not working as expected. Here is a link:
http://live.datatables.net/yanugepo/1/
That doesnt show the indexes, it shows the entire row in the span (SS), and it only shows it when I change pages, it should do it on
dt.draw
And Im not sure how much help I can be with version 1.9.4, you should really be using the most current stable release.. why cant you update that?
I had to do that in "draw.dt" to make that work. Its not optimal (as we don't need to do those as frequent as per draw, only during page change is enough), but works.
Updating is not an option now, however we are considering it.
Thanks a lot for your time and help, jLinux.