Buttons extension not working - "Object doesn't support property or method 'init'"
Buttons extension not working - "Object doesn't support property or method 'init'"
I'm trying out the buttons extension for Datatables (specifically the Excel button), and I'm having trouble getting it to work. My code looks just like the example code, but I'm getting "Object doesn't support property or method 'init'" on my datatables.buttons.min.js file. Is there a specific version of jQuery I should be using for this extension? I'm currently using jQuery 2.1.3, because I was getting a similar error when I was starting out with Datatables and that was the only version that made everything work. See my code below and please let me know if you see something that I'm doing wrong.
$(document).ready(function() {
$('#example').DataTable({
dom: 'Bfrtip',
buttons: [
'excelHtml5'
]
});
});
And above that I'm loading my scripts in this order:
jquery-2.1.3.min.js
jquery.datatables.min.js
datatables.buttons.min.js
jszip.min.js
buttons.html5.min.js
This question has an accepted answers - jump to answer
Answers
Some steps to look at:
datatables.buttons.min.js
andbuttons.html5.min.js
are the same version.buttons.dataTables.min.css
Beyond that your code looks like it should work. Can you post a link to your page or a test case showing the issue?
Kevin
I took all the steps you mentioned and was still getting the same error. Then, just to make sure, I updated my jquery.dataTables.min.js and jquery.dataTables.min.css, and that fixed it.
Thanks!
Now that I have this working, I have another question.
The Excel button works great, but it seems to have taken the place of the "Show X Entries" drop down menu. Is there a way to have both the Excel button and the "Show X Entries" drop down menu show up side by side?
You need to add the
l
option todom
. Should look something like this:Kevin