Uncaught TypeError: this.movie.setSheetName is not a function bug
Uncaught TypeError: this.movie.setSheetName is not a function bug
mesqueeb
Posts: 38Questions: 12Answers: 1
Dear Community,
I'm trying to add the 'excel' button like this:
$('#table2excel').DataTable({
dom: 'frtipB',
buttons:['excel']
});
But it bugs and gives me that movie.setSheetName bug in console.log.
It happens on: buttons.flash.min.js:9
Uncaught TypeError: this.movie.setSheetName is not a function
I have added the correct dependencies:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
//CSS:
<link rel="stylesheet" href="<?php bloginfo('template_url'); ?>/frameworks/DataTables-1.10.11/media/css/jquery.dataTables.css">
<link rel="stylesheet" href="<?php bloginfo('template_url'); ?>/frameworks/DataTables-1.10.11/extensions/Buttons/css/buttons.jqueryui.css">
//JS:
<script src="<?php bloginfo('template_url'); ?>/frameworks/DataTables-1.10.11/media/js/jquery.dataTables.min.js"></script>
<script src="<?php bloginfo('template_url'); ?>/frameworks/DataTables-1.10.11/extensions/Buttons/js/dataTables.buttons.min.js"></script>
<script src="<?php bloginfo('template_url'); ?>/frameworks/DataTables-1.10.11/extensions/Buttons/js/buttons.flash.min.js"></script>
<script src="<?php bloginfo('template_url'); ?>/frameworks/DataTables-1.10.11/extensions/Buttons/js/buttons.html5.min.js"></script>
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
What version of Buttons are you using? That function was introduced in 1.1.1. Buttons 1.1.2 is the current release version.
Allan
Dear allan,
I just got buttons in the zip package called "Download DataTables v1.10.11" I got from this page:
http://www.datatables.net/download/packages
I tried to find the version number of the buttons inside this zip, but I couldn't find it anywhere...
It was 1.1.2, but I tried adding the single extension as well, and nothing changed.
I tried adding the non-minified version and the bug is here:
On the previous last line where is says
this.movie.setSheetName(newText);
it says that this "setSheetName" is not a function...It works on the examples/initialisation/export.html included in the Buttons folder.
I've even tried disabling all other scripts on the page, but it still won't work........ Only if I replace the whole page contents with the example page contents it works.
I'm not sure how to look for what is conflicting with the code.
Any ideas on where or how to search for what's causing the bug?
After trying to debug a whole day today, I found out the plugin bugs when your table is inside a div with style="display:none;" ...
<
div style="display: none;">
I will report this bug to the authors I guess, but in the mean time, do not use a div with style="display: none;".
I haven't found a way yet to hide the table and then make it work after unhiding it.
It also only seems to break the 'excel' button. It would be great if you could fix this.
The real reason is probably because it needs the following dependencies, even though it's documented nowhere clearly... I've added these to the head scripts and it works:
Why are these scripts required for the excel button?
I can't find these scripts in the package, I downloaded. Am I overseeing some guide on how to be able to export to excel? Because I can't find any information on these links anywhere...
Does anyone know what they do and why they are required?
Initialising the table in a
display:none
element will indeed cause problems for Flash export, but this is a known "issue" (not a bug - it is simply how Flash works) and how to resolve it is described in this example using thebuttons.resize()
API method.Alternatively you could not use the Flash export option at all, just use the HTML5 export options which don't have that limitation.
Allan
Just for a future reference, are all of the following libraries required for exporting through excel?
And can I only add them through these online websites? Because I couldn't find them in the zip package. =S
No - the pdfmake and pdf fonts files (vfs_fonts) are not required for Excel export.
The DataTables download is the easiest way of building a package that suits your needs.
Allan