Format individual cells
Format individual cells
sspagna
Posts: 3Questions: 0Answers: 0
I have the problem to format individual cells depending on its content.
how to do?
Example:
If the cell n° 2 has a value = 35 in column 3 = 35 the cell red for all tables
This discussion has been closed.
Replies
I'm not sure I understand your example perfectly, but perhaps you could try something like:
There is a function that tells me the index of the td?
If you want the index of a specific td, use
cell().index()
, it returns an object that looks like:So you might use that in this way:
Or if you want to color based on the data in the table:
// for set data
var tableApi = $('#theTable').DataTable();
tableApi.$('td').each( function() {
if ( tableApi.cell(this).data() == 5 ) {
tableApi.cell(this).data(<a herf="">5</a>);
}
}
this does it?
and then I do the redraw?
Seems like that should work. Only way to know for sure is to try :)