fnClick callback on TableTools flash button breaks CSV/XLS export.
fnClick callback on TableTools flash button breaks CSV/XLS export.
This works just fine:
[code]
"oTableTools": {
"sSwfPath": "swf/copy_csv_xls_pdf.swf",
"aButtons": [
{
"sExtends": "xls",
"sButtonText": "Excel",
"mColumns": [0, 1, 2, 3, 4, 5, 6, 7]
},
"copy",
"pdf"
]
}
[/code]
However, when adding the fnClick callback described here: http://datatables.net/extras/tabletools/button_options#fnClick like so:
[code]
"oTableTools": {
"sSwfPath": "swf/copy_csv_xls_pdf.swf",
"aButtons": [
{
"sExtends": "xls",
"sButtonText": "Excel",
"mColumns": [0, 1, 2, 3, 4, 5, 6, 7],
"fnClick": function ( nButton, oConfig, oFlash ) {
console.log(oConfig);
}
},
"copy",
"pdf"
]
}
[/code]
The exported csv or xls file only contains 1 empty row and column. Tested in Chromium build 18, Open office to check CSV/XLS output.
[code]
"oTableTools": {
"sSwfPath": "swf/copy_csv_xls_pdf.swf",
"aButtons": [
{
"sExtends": "xls",
"sButtonText": "Excel",
"mColumns": [0, 1, 2, 3, 4, 5, 6, 7]
},
"copy",
"pdf"
]
}
[/code]
However, when adding the fnClick callback described here: http://datatables.net/extras/tabletools/button_options#fnClick like so:
[code]
"oTableTools": {
"sSwfPath": "swf/copy_csv_xls_pdf.swf",
"aButtons": [
{
"sExtends": "xls",
"sButtonText": "Excel",
"mColumns": [0, 1, 2, 3, 4, 5, 6, 7],
"fnClick": function ( nButton, oConfig, oFlash ) {
console.log(oConfig);
}
},
"copy",
"pdf"
]
}
[/code]
The exported csv or xls file only contains 1 empty row and column. Tested in Chromium build 18, Open office to check CSV/XLS output.
This discussion has been closed.
Replies
[code]
this.fnSetText( flash, this.fnGetTableData(oConfig) );
[/code]
however, since you have overridden the fnClick - it now only has your console.log... :-). So you need to include the original code as well. This is does to allow complete customisation of what happens which the button is clicked.
Allan
[code]
"fnClick": function ( nButton, oConfig, oFlash ) {
this.fnSetText(oFlash, this.fnGetTableData(oConfig));
console.log(oConfig);
}
[/code]