The equivalent syntax since DataTables 1.10+ is rowCallback
"rowCallback": function( row, data, index ) {
if ( data[2] == "5" )
{
$('td', row).css('background-color', 'Red');
}
else if ( data[2] == "4" )
{
$('td', row).css('background-color', 'Orange');
}
}
One of the previous answers mentions createdRow
. That may give similar results under some conditions, but it is not the same. For example, if you use draw()
after updating a row's data, createdRow
will not run. It only runs once. rowCallback
will run again.