sebastienheyd / boilerplate

Laravel AdminLTE 3 Boilerplate package with blade components, users, roles and permissions management
MIT License
219 stars 66 forks source link

Datatable buttons are not working #46

Closed lawsjas closed 3 years ago

lawsjas commented 3 years ago

I am having an issue with Datatables where I am not able to add copy, excel, pdf buttons.

I've tried changing the dom to: dom: 'Bfrtip', buttons: [ 'copy', 'excel', 'pdf' ]

The css of the datatables are messed up and no buttons are displaying.

My blade code image

My preview image

sebastienheyd commented 3 years ago

This happens because DataTables is used with Bootstrap 4.

https://datatables.net/extensions/buttons/examples/styling/bootstrap4

You also need to load some additional scripts after @include('boilerplate::load.datatables', ['buttons' => true]) to make buttonswork :

@push('plugin-js')
<script src="{!! mix('/plugins/datatables/plugins/'.$plugin.'.bootstrap4.min.js', '/assets/vendor/boilerplate') !!}"></script>
@endpush

I will add these features to the blade component <x-boilerplate::datatable> : https://sebastienheyd.github.io/boilerplate/components/datatable

sebastienheyd commented 3 years ago

I've just added the buttons feature to the datatable component with the release 7.10.4

I strongly encourage you to use the datatable generator : https://sebastienheyd.github.io/boilerplate/datatables/create

You can also see a real example because the generator has been used for the users list : https://github.com/sebastienheyd/boilerplate/blob/master/src/Datatables/UsersDatatable.php