Buttons don't appear

Buttons don't appear

hellsinghellsing Posts: 22Questions: 8Answers: 0

Hi All,

I just started a project with DataTables. I try to use Buttons extension. I think I have the correct code but the buttons don't appear on the page. Otherwise DT works properly (pagination, ordering, search, etc.). I hadn't got error message visible on the page or on the console.

I have jQuery 3.1.1 and DT is the only jQuery plug-in in use. I thought it was a CSS conflict but I don't get the buttons even if I completely switch off my CSS.

My CDN link:
https://cdn.datatables.net/v/dt/jszip-2.5.0/pdfmake-0.1.18/dt-1.10.12/b-1.2.2/b-colvis-1.2.2/b-html5-1.2.2/b-print-1.2.2/cr-1.3.2/r-2.1.0/datatables.min.js

CSS:
https://cdn.datatables.net/v/dt/jszip-2.5.0/pdfmake-0.1.18/dt-1.10.12/b-1.2.2/b-colvis-1.2.2/b-html5-1.2.2/b-print-1.2.2/cr-1.3.2/r-2.1.0/datatables.min.css

...and initialization:

$(document).ready(function() {
    $('#bugsData').DataTable({
        buttons: [ 'copy', 'excel', 'pdf' ]
    });
} );

Any hint would be appreciated.

This question has an accepted answers - jump to answer

Answers

  • tangerinetangerine Posts: 3,342Questions: 35Answers: 394

    Your CDN link for js doesn't include Buttons. You need to include it with the download builder.

  • allanallan Posts: 61,452Questions: 1Answers: 10,055 Site admin
    Answer ✓

    It looks like it does include Buttons (b-1.2.2) - but what is missing is the dom option that is used in the examples for Buttons.

    Allan

  • tangerinetangerine Posts: 3,342Questions: 35Answers: 394

    My apologies - missed that.

  • hellsinghellsing Posts: 22Questions: 8Answers: 0

    Oh, thanks a lot! I followed the first example from the Extension page and I just realized it's not enough if I just made an instance of buttons.

    Now I have the buttons over the left-top corner of my table but the select element for number of lines per page disappeared... I found out that I have to add the letter 'l' (Lima) to get it back.

  • allanallan Posts: 61,452Questions: 1Answers: 10,055 Site admin

    I found out that I have to add the letter 'l' (Lima) to get it back.

    Yup. That one is in the FAQs.

    Frankly the dom parameter is a major PITA. It works, but it requires more thinking about that it should do for an initialisation option. I'm planning to make this soft of thing much easier in the next major version of DataTables. Thanks for your feedback on it :smile:.

    Allan

  • hellsinghellsing Posts: 22Questions: 8Answers: 0

    Thanks for your support :smile:

    Peter

This discussion has been closed.