How to add row design base on condition?
How to add row design base on condition?
 jer040506            
            
                Posts: 5Questions: 3Answers: 0
jer040506            
            
                Posts: 5Questions: 3Answers: 0            
            <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.createdCellorcreatedRowfor this. If the data can change then you would userowCallbackinstead as it runs each time the row is displayed.Kevin
Kevin's right, I'm wrong.