public function dataTable($query)
{
return datatables($query)
->addColumn('action', function() {
// From here you may:
// 1. build your HTML
$html = '<a href="#">LINK</a>';
// 2. Render a view
$view = view('users.partials.action-cell');
$html = (string)$view;
// or
$html = $view->render();
return $html;
});
}
Apr 13, 2020
2
Level 54
Yajra DataTable Package Passing In Additional Data for Add Column
I currently have three tables on one page that all are rendered with the yajra-laravel-datatables package. All three datatables contain an additional column for displaying the actions that can be taken on each model. What I want to be able to do is pass in an array of actions for each datatable action column so that in the `users.partials.action-cell if only does the checks for the actions for that datatable.
DataTable A - Employed Users - view, edit, delete, fire, etc.
DataTable B - Fired Users - view, edit, delete, rehire, etc.
DataTable C - Retired Users - view, edit, delete, rehire
Using the info above I want to be able to pass in only those actions for each DataTable class.
public function dataTable($query)
{
return datatables($query)
->addColumn('action', 'users.partials.action-cell');
}
Level 6
Please or to participate in this conversation.