diff --git a/buttons/export.md b/buttons/export.md index eef8400..febf73e 100644 --- a/buttons/export.md +++ b/buttons/export.md @@ -105,6 +105,40 @@ class UsersDataTable extends DataTable ... ``` + +## Export as Excel, CSV, and PDF using POST method + +To enable exporting to excel, csv, and pdf using POST method set the following on the buttons array. +This is recommended if you have a long query and if you are using IE browsers. + +```php +namespace App\DataTables; + +use App\User; +use Yajra\DataTables\Services\DataTable; + +class UsersDataTable extends DataTable +{ + //...some default stubs deleted for simplicity. + + public function html() + { + return $this->builder() + ->columns($this->getColumns()) + ->parameters([ + 'buttons' => ['postExcel', 'postCsv', 'postPdf'], + ]); + } +... +``` + +And also add this code to your routes.php file. +```php + Route::resource('sample', 'SampleController@index'); + Route::post('sample/export', 'SampleController@index'); +... +``` + ## Printable Version