Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions buttons-custom.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Custom Actions

You can enable custom actions on your buttons, as follows:

Update `UsersDataTable` class and overload the `actions` property. Here we are
disabling the `csv` and `pdf` action (so they cannot be fired by hijacking the
request) and enabling a `myCustomAction`.


```php
namespace App\DataTables;

use App\User;
use Yajra\Datatables\Services\DataTable;

class UsersDataTable extends DataTable
{
protected $actions = ['print', 'excel', 'myCustomAction'];

public function html()
{
return $this->builder()
->columns($this->getColumns())
->parameters([
'dom' => 'Bfrtip',
'buttons' => ['print', 'excel', 'myCustomAction'],
]);
}

public function myCustomAction()
{
//...your code here.
}

}
```

Take a look at `Yajra\Datatables\Services\DataTable` to see how to fetch and manipulate the data (functions `excel`, `csv`, `pdf`).
1 change: 1 addition & 0 deletions documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
- [Configuration](/docs/{{package}}/{{version}}/buttons-config)
- [Quick Starter](/docs/{{package}}/{{version}}/buttons-starter)
- [DataTable Buttons](/docs/{{package}}/{{version}}/buttons-export)
- [Custom Actions](/docs/{{package}}/{{version}}/buttons-custom)
- [Extended DataTable](/docs/{{package}}/{{version}}/buttons-extended)
- [Artisan Console](/docs/{{package}}/{{version}}/buttons-console)
- [Github](https://github.com/yajra/laravel-datatables-buttons)
Expand Down