Using createdRow
option is the correct way to do it.
For example:
$('#example').DataTable({
'createdRow': function( row, data, dataIndex ) {
$(row).addClass( 'bill-row' );
}
});
However you’re retrieving rows incorrectly. Using $(".bill-row")
will return rows on the current page only.
As an alternative use $()
API method instead.
For example:
var row = $('#example').DataTable().$('.bill-row');
OR
I like the rowCallback
option:
table = $('#resultTable').DataTable({
aaSorting: [],
ajax: {...},
columnDefs: [...],
rowCallback: function (row, data) {
if (data.IsDeleted) {
$(row).addClass('redRow');
}
}
});