How do I get ids of visible rows?
How do I get ids of visible rows?
ayz
Posts: 63Questions: 23Answers: 1
in DataTables 2
Is there a function to get the ids of currently visible rows?
I'm aware of 'start' and 'end' of page.info() but depending on how the data is sorted, I presume indexes of the visible rows cannot be assumed to be sequential.
Or is it the case that the indexes stay the same and rows simply get re-arranged?
This question has accepted answers - jump to:
Answers
Use
rows().indexes()
with theselector-modifier
of{ page: "current" }
. For example:The each row's index is assigned when its added to the Datatable. The index does not change.
Kevin
There is also
rows().ids()
if you specifically want theid
attribute of the rows, rather than the indexes. Which would be better will depend on what you are looking to do. Perhaps you could explain further?Allan
Yes, thank you both. I'm doing this currently:
Line 1 isn't needed there - just do:
Allan