datatables github code example
Example 1: datatable
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/v/dt/dt-1.10.22/datatables.min.css"/>
<script type="text/javascript" src="https://cdn.datatables.net/v/dt/dt-1.10.22/datatables.min.js"></script>
Example 2: yajra datatables html column bulder example
public function getMethod(Request $request, Builder $htmlBuilder)
{
if ($request->ajax()) {
return Datatables::of(User::select(['id', 'name', 'email', 'created_at', 'updated_at']))->make(true);
}
$html = $htmlBuilder->addColumn(['data' => 'id', 'name' => 'id', 'title' => 'Id'])->addColumn(['data' => 'name', 'name' => 'name', 'title' => 'Name'])->addColumn(['data' => 'email', 'name' => 'email', 'title' => 'Email'])->addColumn(['data' => 'created_at', 'name' => 'created_at', 'title' => 'Created At'])->addColumn(['data' => 'updated_at', 'name' => 'updated_at', 'title' => 'Updated At']);
return view('datatables.html.method', compact('html'));
}