To enable export button group, set export
on the buttons array.
Export button group includes excel
, csv
and pdf
button.
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' => ['export'],
]);
}
...
To enable exporting to excel, set excel
on the buttons array.
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' => ['excel'],
]);
}
...
To enable exporting to csv, set csv
on the buttons array.
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' => ['csv'],
]);
}
...
To enable exporting to pdf, set pdf
on the buttons array.
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' => ['pdf'],
]);
}
...
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.
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.
Route::resource('sample', 'SampleController@index');
Route::post('sample/export', 'SampleController@index');
...
To enable print button, set print
on the buttons array.
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' => ['print'],
]);
}
...
To enable reset button, set reset
on the buttons array.
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' => ['reset'],
]);
}
...
To enable reload button, set reload
on the buttons array.
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' => ['reload'],
]);
}
...