-
Notifications
You must be signed in to change notification settings - Fork 58
Serverside datatables #9
Copy link
Copy link
Open
Description
When creating datatables to find data from database using serverside method of datatables then view of table is something like attached screenshot.
JS code
`
function loadDatatable() {
$('.serverside').DataTable({
serverSide: true,
ajax: "{{url('admin/entry/list-entries-datatables')}}",
lengthMenu: [[25, 100, -1], [25, 100, "All"]],
pageLength: 25,
columns: [
{ data: "check",name:"check" },
{ data: "id",name:"ID" },
{ data: "customer_id",name:"customer_id" },
{ data: "entry_type",name:"entry_type" },
{ data: "department",name:"department" }
]
// other options
});
}
`
Controller
`
$entries = Entry::select(['id', 'customer_id', 'entry_type', 'department','total_amount']);
if ($request->has('customer_id')) {
$entries =$entries->where('customer_id', $request->customer_id);
}
$entries =$entries->with(['entryTypeDetails', 'departmentDetails', 'customer']);
$entries =$entries->get();
return Datatables::of($entries)->make(true);
`
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
