Formatting cells based on another column
Formatting cells based on another column

I'm using:
columnDefs: [
{
targets: 7,
createdCell: function (td, cellData, rowData, row, col) {
if ( cellData < "D" ) {
$(td).css('color', 'white')
$(td).css('background-color', 'red')
} else {
$(td).css('color', 'white')
$(td).css('background-color', 'blue')
}
}
} ],
to highlight a column red or blue based on values within that column.
Can the code be adapted to highlight a column based on values in a different column?
Thanks
This discussion has been closed.
Replies
Yep, note the third argument is
rowData
- you can use that in your logic too...Great, thanks Colin I'll give it a go!
To answer my own question, the following code highlights the 10th and 11th columns, based on the value in the 12th column: