[Q] Is there a link between a DOM TR (or TD) and the corresponding data object?

[Q] Is there a link between a DOM TR (or TD) and the corresponding data object?

spacewrenchspacewrench Posts: 5Questions: 2Answers: 0

I have a table that is populated with properties from objects in an array of objects. I'd like to be able to style particular cells in the table, based on information that I have when I'm preparing the array of objects. For example, one of my columns is a date, and I'd like to highlight cells that contain dates within +/- 30 days of today (or, perhaps, +/- 30 days of a date that's elsewhere in the UI). It would be easy to add auxiliary information to each object in the array, saying whether there should be special styling in the row corresponding to the object, or in a particular cell of the row.

I think the easiest way to do this is in the on('preDraw') callback -- I think the DOM table is complete, and could easily be tweaked at that point. I can get the DOM table from the preDraw event (at event.currentTarget) but I don't know how to get from the <tr>'s or <td>'s to the corresponding object.

Is this possible? The wrong way of thinking about it? Is there a DataTables way of doing it that I'm not understanding in the manual pages?

Thanks!

This question has an accepted answers - jump to answer

Answers

This discussion has been closed.