Buttons don't appear
Buttons don't appear
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.
...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
Your CDN link for js doesn't include Buttons. You need to include it with the download builder.
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
My apologies - missed that.
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.
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 .Allan
Thanks for your support
Peter