I've install datatable-button, all js, and all css but still get json format not download the pdf. The data can show, just cannot download the data
Here is it my controller
return DataTables::of(Permission::query())
->addIndexColumn()
->addColumn('actions', function ($users) {
return ActionHelper::showUpdateDeleteButton('superadmin.permissions', $users->id);
})
->rawColumns(['actions'])
->make(true);
Here is it the js
$('#dataTable').DataTable({
processing: true,
serverSide: true,
ajax: '{!! route('superadmin.permissions.datatable') !!}',
columns: [
{ data: 'DT_RowIndex', name: 'DT_RowIndex' , orderable: false, searchable: false},
{ data: 'id', name: 'id' },
{ data: 'name', name: 'name' },
{ data: 'created_at', name: 'created_at' },
{ data: 'updated_at', name: 'updated_at' },
{ data: 'actions', name: 'actions' }
],
dom: 'lBfrtip',
buttons : [
{extend: 'colvis', postfixButtons: [ 'colvisRestore' ] },
{extend:'csv'},
{extend: 'pdf', title:'File PDF Datatables'},
{extend: 'excel', title: 'File Excel Datatables'},
{extend:'print',title: 'Print Datatables'},
]
});
You need to use the service class of DataTable to be able to use the server-side buttons.
Quick start, use the command below:
php artisan datatables:make Permission
See https://yajrabox.com/docs/laravel-datatables/master/buttons-starter for ref.
Oke thank you. I've convert my datatable to use service class of datatable 👍🏻
Most helpful comment
You need to use the service class of DataTable to be able to use the server-side buttons.
Quick start, use the command below:
See https://yajrabox.com/docs/laravel-datatables/master/buttons-starter for ref.