Can't use colvis from datatables-buttons npm package

Can't use colvis from datatables-buttons npm package

rowdmaprowdmap Posts: 1Questions: 1Answers: 0

After installing datatables-buttons from npm, it seems to load properly, but throws this error when trying to use the colvis button: Cannot extend unknown button type: colvis

I've tried looking around for other npm packages like datatables-buttons-colvis, but I haven't been able to find any. Is there a way to use the column visibility plugin with the buttons npm package?

Answers

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin

    Hi,

    The datatables.net-buttons package includes the scripts for column visibility control, HTML5 export, Flash export and Print view, but they are not included by default. Instead what you need to do is add them to your require statements - for example you might do:

    require('datatables.net')();
    require('datatables.net-buttons')();
    require('datatables.net-buttons/js/buttons.colVis.js')();
    

    The last line simply does an include of that specific file from the datatables.net-buttons package.

    The files for the buttons are:

    • js/buttons.colVis.js
    • js/buttons.flash.js
    • js/buttons.html5.js
    • js/buttons.print.js

    Regards,
    Allan

This discussion has been closed.