"Uncaught Cannot extend unknown button type: copyHtml5" - How to use `datatables.net-buttons-bs4`
"Uncaught Cannot extend unknown button type: copyHtml5" - How to use `datatables.net-buttons-bs4`
I have installed Datatables via npm:
npm install --save datatables.net-bs4
npm install --save datatables.net-buttons-bs4
and want to use the buttons.html5
js file too.
Before I started working with npm packages I used datatables CDNs like this:
<script src="//cdn.datatables.net/1.10.19/js/jquery.dataTables.min.js" crossorigin="anonymous"></script>
<script src="https://cdn.datatables.net/buttons/1.5.2/js/dataTables.buttons.js" crossorigin="anonymous"></script>
<script src="https://cdn.datatables.net/buttons/1.0.0/js/buttons.html5.min.js" crossorigin="anonymous"></script>
Now I import it like this:
// Datatables
import 'datatables.net-bs4';
// Datatables - Buttons
import 'datatables.net-buttons-bs4';
My script uses the buttons.js feature with the HTML5 (file exist in the folder node_modules/datatables.net-buttons/js/buttons.html5.js
. but it seems like it's not imported properly using import 'datatables.net-buttons-bs4';
therefore, resulting the error:
Uncaught Cannot extend unknown button type: copyHtml5
in the console, pointing the a row using the feature:
this.tableDownload = new $.fn.dataTable.Buttons(this[this.tableDisplayed], {
Which worked fine when using the CDNs.
Answers
Yes, you need to import the plug-in file you want:
I think should do it.
Allan