DataTables Buttons not showing in Semantic UI using Node (npm)
DataTables Buttons not showing in Semantic UI using Node (npm)
I'm using DataTables in a Vue.js application using semantic-ui for styling. I have installed the datatables.net-buttons and the datatables.net-buttons-se packages and required them in my app.
When using direct insertion method (both with new constructor and adding buttons option in DataTables initialization), the buttons are not generated. The most happens is the dt-buttons div layer is generated when using the new Buttons constructor method.
I have added pdfmake to my Vue.js-Node application but still no results.
What am I missing?
This question has accepted answers - jump to:
Answers
Not sure. if you link to a test case showing the issue I might be able to offer some help.
Allan
Before I set up a test case. See how I have set up my node application.
The dependencies in my package.json file is as shown below,
I've set up jQuery to be globally accessible using webpack.base.conf.js as so,
jQuery works. I use it accessing the DOM and so on.
I then require datatables.net and its dependencies in the main App.js
Now to the part where the action takes place. The DataTable is initialized and set up with direct insertion as follows,
In the meantime, if I still don't resolve this today, I will set up an equivalent on JSFiddle.
I'm guessing that I'm missing a dependency. What do you think?
Looks like you need to include the Buttons files for export, print, etc. The download builder should help there - click the npm tag at the bottom after selecting what you need and it will show the required imports.
Allan
Ok. I'm seeing some progress after following the documentation that you directed me too.
I require the following in my App.vue
pdfmake was giving me a lot of problems saying that 9 or more dependencies was missing. So I removed it.
I'm going to need the excel. So, here is my package.json now,
After, using direct insertion with new keyword to initialize the Buttons extension, like so,
After doing all the above, I get [Copy] and [Print]. I'm almost happy.
I really need the jszip (SheetJS) to work. It's not showing. I'll send you the screenshot following this.
Here is the screenshot of the progress made on the datatable.
The Excel export doesn't use SheetJS, so if you need SheetJS you'd probably need to write that export button (I'm not aware of one that exists).
My guess as to why the Excel button isn't appearing with the above is that Buttons isn't seeing JSZip for some reason. I'm not sure immediately why that would be. I assume you are using AMD loaders (rather than CommonJS)?
Can you link to the page so I can debug the code directly please.
Allan
So Allan,
I do not have that option to expose the application over the internet right now. It's going to take me some time to set up a test environment for you.
This morning I decided to add some more requirements like the following,
And voila, the [Excel] button shows up.
Here's the thing, though, I click the button and it does not work. LOL.
I'm thinking JSZip is not being seen. Maybe after npm install --save jszip, I need to build with gulp or grunt. Gonna check that out.
Your help has been useful so far. I know you would need to debug the app. I'm going to try and see how I can put this over the internet if I do not find the solution today.
Try this:
I've just tried that in another thread and it appears to work okay.
Allan
It works. Not elegant for Node-Vue.js, but it works.
Can you provide a more elegant solution that fits into Node-Vue.js apps?
(If not, that is OK. You did well)
In what way are you looking for it to be more elegant? I'm not sure what you are looking for - but then I haven't used Vue myself.
Allan
I tried,
But that throws an error.
I'll satisfy with,
The problem with
const JSZip
is that it would still be locally scoped. Usingwindow.JSZip
effectively assigns it to the global scope so that the Buttons extension can see it.The CommonJS loader for Buttons has the option of passing in a JSZip instance, but the AMD loader needs it to be in the global scope.
Allan