From 1d14d47d08af975d28b309480e0212a45ef55142 Mon Sep 17 00:00:00 2001 From: Jerome Sarmiento Date: Fri, 3 Nov 2017 09:07:00 +0800 Subject: [PATCH 1/3] Add Post method Export Instructions --- buttons/export.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/buttons/export.md b/buttons/export.md index eef8400..6498745 100644 --- a/buttons/export.md +++ b/buttons/export.md @@ -105,6 +105,33 @@ 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'], + ]); + } +... +``` + ## Printable Version From 95ede0bb0194f6051df57983b93a0604a1d7ad2c Mon Sep 17 00:00:00 2001 From: Jerome Sarmiento Date: Fri, 3 Nov 2017 09:27:45 +0800 Subject: [PATCH 2/3] change to post-export, add routes instruction --- buttons/export.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/buttons/export.md b/buttons/export.md index 6498745..176f3dd 100644 --- a/buttons/export.md +++ b/buttons/export.md @@ -105,7 +105,7 @@ 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. @@ -132,6 +132,12 @@ class UsersDataTable extends DataTable ... ``` +And also add this code to your routes.php file. +```php + $router->post('sample/export', SampleController::class . '@index'); +... +``` + ## Printable Version From 6523b59f1e6e2547d0a406e94fd990bc9630172c Mon Sep 17 00:00:00 2001 From: Jerome Sarmiento Date: Fri, 3 Nov 2017 09:32:50 +0800 Subject: [PATCH 3/3] change routes instruction --- buttons/export.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/buttons/export.md b/buttons/export.md index 176f3dd..febf73e 100644 --- a/buttons/export.md +++ b/buttons/export.md @@ -134,7 +134,8 @@ class UsersDataTable extends DataTable And also add this code to your routes.php file. ```php - $router->post('sample/export', SampleController::class . '@index'); + Route::resource('sample', 'SampleController@index'); + Route::post('sample/export', 'SampleController@index'); ... ```