No one has ever become poor by giving. - Anne Frank, diary of Anne Frank
Id | Name | Created At | Updated At | Action |
---|
public function getDtRow()
{
return view('datatables.fluent.dt-row');
}
public function getDtRowData()
{
$users = DB::table('users')
->select(['id', 'name', 'email', 'password', 'created_at', 'updated_at']);
return Datatables::of($users)
->addColumn('action', function ($user) {
return '<a href="#edit-'.$user->id.'" class="btn btn-xs btn-primary"><i class="glyphicon glyphicon-edit"></i> Edit</a>';
})
->editColumn('id', '{!!$id!!}')
->removeColumn('password')
->setRowId('id')
->setRowClass(function ($user) {
return $user->id % 2 == 0 ? 'alert-success' : 'alert-warning';
})
->setRowData([
'id' => 'test',
])
->setRowAttr([
'color' => 'red',
])
->make(true);
}
$('#users-table').DataTable({
processing: true,
serverSide: true,
ajax: 'https://yajratables.tuecus.com/fluent/dt-row-data',
columns: [
{data: 'id', name: 'id'},
{data: 'name', name: 'name'},
{data: 'email', name: 'email'},
{data: 'created_at', name: 'created_at'},
{data: 'updated_at', name: 'updated_at'},
{data: 'action', name: 'action', orderable: false, searchable: false}
]
});