How to change text color to a column with render function based on column name not column number
How to change text color to a column with render function based on column name not column number
Hi,
I'm trying to change the color of a text for couple of my columns but also i have colvis function so when i use render function with the number of the column everything works but if i hide a column for example 5 it's changing the color for the next column.Is there an option to change the color based on column name or something like that?
Here is the part of the code that change the color.Thanks
"rowCallback" : function(row, data, index,full){
if (data.Balance > 0){
$('td:eq(8)', row).css('color', 'red');
}
This question has an accepted answers - jump to answer
Answers
Try using
column().index()
to select the column based on visibility. For example:If a column is removed and column 8 shifts left then
.index('visible')
will take that into account andcol
will be 7.Kevin
That worked great..Thank you!