Buttons don't appear on the data table
Buttons don't appear on the data table
Bavario
Posts: 5Questions: 2Answers: 0
I'd like to have an option to export my dataTable as CSV, XLSX or just to print it, however this doesn't work. When using this code:
$("#hourTable").dataTable({
buttons: [
'csv', 'excel', 'print'
],
language: {
url: "frameworks/de_de.json"
},
lengthMenu: [[10, 20, 30], [10, 20, 30]],
order: [[1, "desc"]]
});
It produces the following output:
Even when checking the HTML using the console, I cannot find those buttons anywhere.
Is there a setting I applied that cancels it out? Or is there something else I'm doing wrong?
Thanks in advance
This question has an accepted answers - jump to answer
Answers
You need to use one of the options here to display the buttons. Generally the -option dom` option is the easiest. See the basic buttons example.
Kevin
@kthorngren Thank you for your answer. Sadly, adding the dom property does not work. Here's my code with the dom property:
And here is the output it produces:
So, this sadly doesn't work for me even though the tutorial you linked claimes otherwise.
How are you referencing the Buttons extension?
https://datatables.net/extensions/buttons/
Oh. I didn't know an extension was necessary
Well, that explains it. Thanks for letting me know!