How do I get ids of visible rows?
How do I get ids of visible rows?
![ayz](https://secure.gravatar.com/avatar/aa69d23a55e5c52d8e32d35f0d60cb48/?default=https%3A%2F%2Fvanillicon.com%2Faa69d23a55e5c52d8e32d35f0d60cb48_200.png&rating=g&size=120)
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