Open alexander-zugan opened 9 years ago
Hi,
this is very easy to implement.
For V.3 use this: http://sleeping-owl.github.io/v3/en/Displays.html --> Bulk Actions
What you have to do is the following:
Column::checkbox()
to your display columns. Something like this:display()
function$display->actions([
Column::action('export')->value('Export')->icon('fa-share')->target('_blank')->callback(function ($collection)
{
dd('You are trying to export:', $collection->toArray());
}),
...
]);
This is the example from the documentation, you have to change it to whatever you need...
Here is a short example:
Admin::model('App\Model')->title('Title')->display(function ()
{
$display = AdminDisplay::datatables();
$display->columns([
Column::checkbox(),
Column::string('id')->label('#'),
//some other columns
]);
$display->actions([
Column::action('massdelete')->value('Massdelete')->icon('fa-trash')->callback(function ($collection)
{
foreach ($collection->toArray() as $key => $delete_item) {
$item = App\Model::find($delete_item['id']);
//http://laravel.com/docs/5.1/eloquent#deleting-models
$item->delete();
}
}),
//more actions
]);
return $display;
}
Hope this helps :)
Thanks ,but i use v2 ... It is possible to make for v2 ??
I don't know - but I didn't see any in the V2 documentation. Maybe @sleeping-owl can say something?
Otherwise - upgrade to V.3 :)
I very late saw the v3 version and now only on the following project I will use v3 . But now it is necessary to think up something for v2 ...
Maybe you can add the actions()
function to v2:
https://github.com/sleeping-owl/admin/blob/development/src/SleepingOwl/Admin/Display/DisplayTable.php#L192
I didn't work with V.2, don't know where to implement it in V.2 - sorry :(
V.2 has no Column::checkbox() ((
In current (latest) version displays functionality is missing. Is there any way to perform bulk operations?
Вот так можно $display->setActions([ AdminColumn::action('delete', ' Удалить')->setIcon('fa fa-share')->setAction(route('admin_massdelete'))->useGet(), ])
Ну, а в контроллер по указаному роуту, уже делаешь уделание или что тебе нужно
How can i make Mass removal in Admin Panel ??