Skip to content

Commit 305bdba

Browse files
authored
Merge pull request yajra#2 from underdpt/7.0
Custom button actions documentation
2 parents f799f61 + aba4cd9 commit 305bdba

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

buttons-custom.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Custom Actions
2+
3+
You can enable custom actions on your buttons, as follows:
4+
5+
Update `UsersDataTable` class and overload the `actions` property. Here we are
6+
disabling the `csv` and `pdf` action (so they cannot be fired by hijacking the
7+
request) and enabling a `myCustomAction`.
8+
9+
10+
```php
11+
namespace App\DataTables;
12+
13+
use App\User;
14+
use Yajra\Datatables\Services\DataTable;
15+
16+
class UsersDataTable extends DataTable
17+
{
18+
protected $actions = ['print', 'excel', 'myCustomAction'];
19+
20+
public function html()
21+
{
22+
return $this->builder()
23+
->columns($this->getColumns())
24+
->parameters([
25+
'dom' => 'Bfrtip',
26+
'buttons' => ['print', 'excel', 'myCustomAction'],
27+
]);
28+
}
29+
30+
public function myCustomAction()
31+
{
32+
//...your code here.
33+
}
34+
35+
}
36+
```
37+
38+
Take a look at `Yajra\Datatables\Services\DataTable` to see how to fetch and manipulate the data (functions `excel`, `csv`, `pdf`).

documentation.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@
7878
- [Configuration](/docs/{{package}}/{{version}}/buttons-config)
7979
- [Quick Starter](/docs/{{package}}/{{version}}/buttons-starter)
8080
- [DataTable Buttons](/docs/{{package}}/{{version}}/buttons-export)
81+
- [Custom Actions](/docs/{{package}}/{{version}}/buttons-custom)
8182
- [Extended DataTable](/docs/{{package}}/{{version}}/buttons-extended)
8283
- [Artisan Console](/docs/{{package}}/{{version}}/buttons-console)
8384
- [Github](https://github.com/yajra/laravel-datatables-buttons)

0 commit comments

Comments
 (0)