Buttons don't appear on the data table

Buttons don't appear on the data table

BavarioBavario 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

  • kthorngrenkthorngren Posts: 21,183Questions: 26Answers: 4,925

    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

  • BavarioBavario Posts: 5Questions: 2Answers: 0

    @kthorngren Thank you for your answer. Sadly, adding the dom property does not work. Here's my code with the dom property:

    $("#hourTable").dataTable({
        dom: 'Bfrtip',
        buttons: [
            'csv', 'excel', 'print'
        ],
        language: {
            url: "frameworks/de_de.json"
        },
        lengthMenu: [[10, 20, 30], [10, 20, 30]],
        order: [[1, "desc"]]
    });
    

    And here is the output it produces:

    So, this sadly doesn't work for me even though the tutorial you linked claimes otherwise.

  • tangerinetangerine Posts: 3,365Questions: 39Answers: 395
    Answer ✓

    How are you referencing the Buttons extension?
    https://datatables.net/extensions/buttons/

  • BavarioBavario Posts: 5Questions: 2Answers: 0

    Oh. I didn't know an extension was necessary :sweat_smile:
    Well, that explains it. Thanks for letting me know!

Sign In or Register to comment.