diff --git a/docs/table-models.md b/docs/table-models.md index 3cce42f..cc66d6b 100644 --- a/docs/table-models.md +++ b/docs/table-models.md @@ -209,6 +209,33 @@ public function query($query) return $query->where('name', 'Like', "%John Doe%")->with('roles', 'permissions'); } ``` +### Buttons +You can specify Table based buttons for available options view Datatables https://datatables.net/reference/button/ +Note: you must use php array not JSON for example +```public $buttons = [ + [ + 'extend' => 'print', + 'text'=> 'Print', + 'exportOptions'=> [ + 'columns'=> [0, ':visible'], + ], + ], + [ + 'extend' => 'csv', + 'text'=> 'Excel', + 'exportOptions'=> [ + 'columns'=> [0, '=>visible'], + ], + 'filename'=> 'CustomFileName', + ], + 'copy', + [ + 'extend'=> 'colvis', + 'className'=> 'btn btn-dark' + ] + ]; +``` + ### Table triggers The table triggers an event everytime something is processed. Below is a list of triggers available diff --git a/src/resources/views/scripts.blade.php b/src/resources/views/scripts.blade.php index 264d33d..4922619 100644 --- a/src/resources/views/scripts.blade.php +++ b/src/resources/views/scripts.blade.php @@ -250,6 +250,7 @@ classes["{{ $view->tableId }}"] = new class order: view.order, columns: view.columns, columnDefs: this.buildColumnDefs(view.defs), + buttons: {!! json_encode($view->buttons()) ?? [] !!}, createdRow: (row, data, index) => { $(row).on('click', (el) => {