Excel button extension from npm package

Excel button extension from npm package

rink_attendant_6rink_attendant_6 Posts: 16Questions: 4Answers: 1
edited March 2016 in Free community support

I have installed datatables.net-buttons and jszip from npm as I am using Browserify. I am wondering if it is possible to pass in JSZip as a parameter to the Buttons extension (like I do with window and $), as right now it seems to only work if it is a global:

'use strict';

const $  = require('jquery');
const JSZip = require('jszip');

window.JSZip = JSZip; // required to make Buttons extension work for Excel button

require('datatables.net')(window, $);
require('datatables.net-responsive')(window, $);
require('datatables.net-buttons')(window, $);
require('datatables.net-buttons/js/buttons.colVis')(window, $);
require('datatables.net-buttons/js/buttons.html5')(window, $);
require('datatables.net-buttons/js/buttons.print')(window, $);

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 62,211Questions: 1Answers: 10,205 Site admin

    Hi,

    You are correct - at the moment the Buttons extensions require JSZip to be globally available. That is most certainly a flaw in their current setup. I'll need to have a little think about how to best resolve that in the UMD loader, but I think you are right, it should simply be a case of adding an extra parameter to the constructor.

    I'll post back here once I've taken a closer look.

    Regards,
    Allan

  • allanallan Posts: 62,211Questions: 1Answers: 10,205 Site admin
    Answer ✓

    I've committed the fix for this and it will be in Buttons 1.2.

    Thanks for flagging this up!

    Regards,
    Allan

  • rink_attendant_6rink_attendant_6 Posts: 16Questions: 4Answers: 1

    Hi allan,

    Sounds great. Do you have an estimate for when Buttons 1.2 will be available on npm? Some of my team members are eagerly waiting to upgrade in order to remove some of our server-side exporting functionality.

    Thanks,

  • allanallan Posts: 62,211Questions: 1Answers: 10,205 Site admin

    It will be nest week now. Had hoped for today, but I think that's going to slip unfortunately.

    Allan

  • snahrvarsnahrvar Posts: 1Questions: 0Answers: 0

    I've got a similar implementation to the OP. How does Buttons 1.2 implement this?

  • allanallan Posts: 62,211Questions: 1Answers: 10,205 Site admin

    As above, you need to include the individual button definition files from the package.

    Allan

This discussion has been closed.