fnClick not working in TableTools button defintion
fnClick not working in TableTools button defintion
marcfarrow
Posts: 28Questions: 0Answers: 0
Consider the following code. The CSV button works fine and generates a random filename. However, if the "fnClick" attribute is left in the extended PDF button properties, the Save As dialog does not appear.
[code]
TableTools.DEFAULTS.aButtons = [
{
"sExtends": "xls",
"fnClick" : function (nButton, oConfig, flash) {
if (parent && parent.OSDIndex) {
var newfilename = parent.OSDIndex.getSaveAsFilename(nButton, "csv");
if (newfilename != null) {
flash.setFileName(newfilename);
}
}
}
},
{
"sExtends" : "pdf",
"sPdfOrientation" : "landscape",
"sPdfSize" : "letter",
"fnClick" : function (nButton, oConfig, flash) {
if (parent && parent.OSDIndex) {
var newfilename = parent.OSDIndex.getSaveAsFilename(nButton, "pdf");
if (newfilename != null) {
/* using a debugger I have verified that the filename here is valid */
flash.setFileName(newfilename);
}
}
return true;
}
}
];
[/code]
[code]
TableTools.DEFAULTS.aButtons = [
{
"sExtends": "xls",
"fnClick" : function (nButton, oConfig, flash) {
if (parent && parent.OSDIndex) {
var newfilename = parent.OSDIndex.getSaveAsFilename(nButton, "csv");
if (newfilename != null) {
flash.setFileName(newfilename);
}
}
}
},
{
"sExtends" : "pdf",
"sPdfOrientation" : "landscape",
"sPdfSize" : "letter",
"fnClick" : function (nButton, oConfig, flash) {
if (parent && parent.OSDIndex) {
var newfilename = parent.OSDIndex.getSaveAsFilename(nButton, "pdf");
if (newfilename != null) {
/* using a debugger I have verified that the filename here is valid */
flash.setFileName(newfilename);
}
}
return true;
}
}
];
[/code]
This discussion has been closed.
Replies
Thanks.
Thanks.
[code]
if (typeof(TableTools) === "function") {
TableTools.DEFAULTS.sSwfPath = "/vsjs/jQuery/v1_8_2/plugins/TableTools-2_0_1/media/swf/copy_cvs_xls_pdf.swf";
TableTools.DEFAULTS.aButtons = [
{
"sExtends": "xls",
"fnClick" : function (nButton, oConfig, flash) {
if (parent && parent.OSDIndex) {
var newfilename = parent.OSDIndex.getSaveAsFilename(nButton, "csv");
if (newfilename != null) {
this.fnSetText(flash, newfilename)
// flash.setFileName(newfilename);
}
}
}
},
{
"sExtends" : "pdf",
"sPdfOrientation" : "landscape",
"sPdfSize" : "letter"
,
"fnClick" : function (nButton, oConfig, flash) {
}
}
];
}
[/code]
https://github.com/DataTables/TableTools/blob/master/media/js/TableTools.js#L2268
Allan
I will look at this code and implement it.
Thanks Allan!
When the PDF and XLS buttons are clicked, it always presents the Save As Dialog box. Is there a setting (or some other way) to just "view" the document directly without saving to disk?
Thanks.
Marc