fnClick callback on TableTools flash button breaks CSV/XLS export.

fnClick callback on TableTools flash button breaks CSV/XLS export.

gconzettgconzett Posts: 3Questions: 0Answers: 0
edited June 2012 in Plug-ins
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.

Replies

  • allanallan Posts: 63,680Questions: 1Answers: 10,498 Site admin
    The default fnClick contains this code:

    [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
  • gconzettgconzett Posts: 3Questions: 0Answers: 0
    edited June 2012
    Thank you, Allan that worked perfectly:

    [code]
    "fnClick": function ( nButton, oConfig, oFlash ) {
    this.fnSetText(oFlash, this.fnGetTableData(oConfig));
    console.log(oConfig);
    }
    [/code]
This discussion has been closed.