This post shows you how to add a class name to jquery.datatables
datatables add class to tr
To add a class to the row
For example:
$('#table').dataTable( {
"createdRow": function( row, data, dataIndex ) {
$(row).addClass('label-warning');
}
});
$('tr', row) will search for a tr element inside the row provided as context parameter. If you want to add a class to row with conditionally based on the row's data.
$('#table').dataTable( {
"createdRow": function(row, data, dataIndex ) {
if (data[4] == "X" ) {
$(row).addClass('text-95 text-secondary');
}
}
} );