How can I dynamically set background to rows After the table has been created?
How can I dynamically set background to rows After the table has been created?
davidzornosa
Posts: 4Questions: 4Answers: 0
Each row of the table has an attribute called "id".
I want to have a red background for the row whose "id" is 8.
var selectedId = 8;
table.rows().every( function ( rowIdx, tableLoop, rowLoop ) {
if (this.data().id == selectedId) {
$(table.row(rowIdx).node()).css('background-color', 'red'); // <- does not work
$(table.row(rowIdx).node()).addClass("redBackgroundClass"); // <-does not work
}
});
How can I dynamically add a red background to rows based on their id value?
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
I would recommend using the callback function to paint the rows red. Please have a look.