How to get access to the row's data from the DataTables select event?
How to get access to the row's data from the DataTables select event?
I have a handler for the DataTables select event. In that handler I need to examine and possibly change the class of one of the td elements in the selected row. I know that I can use row = dt.row(indexes) to use that row within DataTables. In this case, row is a reference to an _Api array, not a jquery object that I can manipulate. I've tried several things, but I have not figured out how to access the individual td elements, etc. in that row.
I've not found the answer to this in the documentation or forums. Some advice would be most helpful.
This question has an accepted answers - jump to answer
Answers
row().node()
will give you thetr
for the row. You can also usecell().node()
to get a specific cell'std
. Theto$()
will allow you to get a jQuery object from the API. You can combine the examples in theselect
event to achieve the result you want. Here is an example:http://live.datatables.net/nusisije/1/edit
Kevin
Kevin,
Thanks for this answer. I'd been aware that these functions existed, but I hadn't realized that they were what I needed. The example was especially helpful as I'd not visualized how these were to be used when I'd read about them previously.
I think it might help others if the documentation had a link to the example you referred to. That might save someone else some time and puzzlement.
This part of the project is now nearly complete.
Thanks very much,
Tom