1

I'm using laravel 5.7 with elixir wrapper for webpack.

I added Datatables.net fine but Excel export button is not displayed.

This is my vendor.js

require('datatables.net');
require('datatables.net-bs4');
require('jszip');
require('datatables.net-buttons');
require('datatables.net-buttons/js/buttons.flash.js');
require('datatables.net-buttons/js/buttons.html5.js');

however the button Excel shows fine if I just add this to my html

<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.5/jszip.min.js"></script>

I recon, jszip is not being required properly. What is a proper way?

No errors in js console.

jszip was downloaded fine into node_modules, like so

$ npm install jszip --save-dev

2 Answers 2

1

This is vendor.js is working fine:

require('datatables.net');
require('datatables.net-bs4');
window.JSZip = require('jszip');    
require('datatables.net-buttons');
require('datatables.net-buttons/js/buttons.flash.js');
require('datatables.net-buttons/js/buttons.html5.js');
Sign up to request clarification or add additional context in comments.

Comments

0

If you are not using Bootstrap, you should use this:

var table = $('#example').DataTable( {
buttons: [
    'copy', 'excel', 'pdf'
] } );


table.buttons().container()
.appendTo( $('<#elementWhereYouNeddToShowThem>', table.table().container() ) );

1 Comment

the question was mostly about webpack, thank you for your answer

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.