Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected get json format from download excel and pdf yajra datatables #2485

Closed
RayhanYulanda opened this issue Oct 9, 2020 · 2 comments
Closed
Labels

Comments

@RayhanYulanda
Copy link

Summary of problem or feature request

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

Code snippet of problem

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'},
                ]
            });

System details

  • Windows 10
  • PHP Version : PHP 7.3
  • Laravel Version 6.2
  • "yajra/laravel-datatables-buttons": "~4.6",
  • "yajra/laravel-datatables-oracle": "~9.0"
@yajra
Copy link
Owner

yajra commented Oct 10, 2020

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.

@yajra yajra added the question label Oct 10, 2020
@RayhanYulanda RayhanYulanda changed the title Get json format from download excel and pdf yajra datatables Unexpected get json format from download excel and pdf yajra datatables Oct 11, 2020
@RayhanYulanda
Copy link
Author

Oke thank you. I've convert my datatable to use service class of datatable 👍🏻

@github-actions github-actions bot locked and limited conversation to collaborators Oct 15, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants