How to add css style to dynamically generated row?
How to add css style to dynamically generated row?
Hi,
I have a table like this.
var table = $('#example').DataTable();
Then I do this:
table.row.add(someInformation).draw();
I have tried: table.row.add(someInformation).addClass('success').draw();
But the above does not add the 'Success' class defined in my css file to the row that is appended to the datatable. Is that meant to do that? I see that in the addClass() documentation page, there is a legacy warning. Is there a newer way of doing this? I can't see to find anything other than addClass().
Thanks,
Anusha
Answers
Found the answer:
var table = $('#example').DataTable(
"createdRow": function(row, data, dataIndex) {
$(row).addClass(whateverClassYouWantToAdd);
}
);
table.row.add(someInformation).draw();