I already have a datatable, now what I want to do is adding a column and set the value for it not from database but set it manually. The rule is, for the first row I want to set it as "being served" and all rows bellow it as "wait/waiting". And I also want to highlight or make the background color of that first row different from other rows.
this is what I code for my datatable, in controller:
public function get_datatable(){
$tanggal = \Carbon\Carbon::now()->toDateString() ;
$data = antrian_sp::select(['antrian_id','tanggal', 'jam', 'noper', 'nama', 'status'])->where('keterangan','=',0)->whereDate('tanggal','=',$tanggal);
return Datatables::of($data)->addIndexColumn()->addColumn('action', function ($data) {
return '<a href="#" class="btn btn-xs btn-primary insert" id="'.$data->antrian_id.'"><i class="glyphicon glyphicon-user"></i></a>
<a href="#" class="btn btn-xs btn-danger delete" id="'.$data->antrian_id.'"><i class="glyphicon glyphicon-trash"></i></a>
<a href="#" class="btn btn-xs btn-success ok" id="'.$data->antrian_id.'"><i class="glyphicon glyphicon-ok"></i></a>';
})
->make(true);
}
The Ajax/javascript:
$('#daftar-antrian').DataTable({
"processing": true,
"serverSide": true,
"ajax" : '/daftar_antrian/get_datatable',
"columns" : [
{data: 'DT_Row_Index', orderable: false, searchable: false},
{data: 'noper', name: 'noper'},
{data: 'nama', name: 'nama'},
{data: 'status', name: 'status'},
{data: 'status', name: 'status'}
],
"scrollY" : "200px",
"scrollCollapse": true,
"info" : true,
"paging" : true,
"searching" : false,
"paging" : false,
"info" : false
});
Please give me some ideas guys, thanks before.