Change background color of first cells of rows
Change background color of first cells of rows

Hello,
I search for rows whose third column value is equal to 'AAA'
var table = $('#jobs-table').DataTable();
var indexes = table.rows().eq(0).filter(function (rowIdx) {
return table.cell(rowIdx, 3).data() == 'AAA'? true : false;
});
then I want to format the first cell with dard background color. But I don't know why. Could you please help? Here is the code to format the whole row that I found on your website. but I cannot use it to format only the first cell of the rows.
table.rows(indexes)
.nodes()
.to$()
.addClass('bg-dark');
Please help
Thank you
This discussion has been closed.
Answers
Your code snippet works here:
http://live.datatables.net/gitiquba/1/edit
Are you using Bootstrap?
Have you inspected the page to see if the class is applied to the row?
Can you post a link to your page or update my example to show the issue?
EDIT: Not sure of your requirements but you can do this using
columns.createdCell
,createdRow
orrowCallback
.Kevin
Thank you for your quick answer @kthorngren .
In fact, I would like to change background color of the first cell of the row (it means the cell that contains "Cedric Kelly" in your example). Not the whole row. Do you know how to do that?
Thanks
Use
cells().nodes()
instead ofrows().nodes()
, for example:http://live.datatables.net/gitiquba/2/edit
Kevin
Wonderful @kthorngren
Thank you very much
