How to add row design base on condition?
How to add row design base on condition?

<style>
.red {
background-color: red !important;
}
</style>
$(function() {
var table = $('#item').DataTable({
processing: false,
serverSide: true,
ajax: '{!! route('admin.get.item') !!}',
columns: [
{ data: 'item_name', name: 'item_name' },
{ data: 'item_quantity',
***if item quantity is less than 5****
if( row.item_quantity === '5')
{
$(row).addClass('red');
}
else
{
}
},
]
});
});
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
You need columns.render:
https://datatables.net/manual/data/renderers#Functions
You would use either
columns.createdCell
orcreatedRow
for this. If the data can change then you would userowCallback
instead as it runs each time the row is displayed.Kevin
Kevin's right, I'm wrong.