jQuery DataTables - 文件名动态更改后文件变空

时间:2014-12-24 17:06:06

标签: csv datatables tabletools

我想动态更改导出的CSV文件名。

accountsDataTable = $('#accounts-list').DataTable({
    "dom": 'Tlfrtip',
    "tableTools": {
        "sSwfPath": "swf/copy_csv_xls.swf",
        "aButtons": [{
            "sExtends": "csv",
            "sTitle": "Temporaire",
            "sButtonText": "Exporter en CSV",
            "mColumns": "visible",
            "fnClick": function ( nButton, oConfig, oFlash ) {
                oFlash.setFileName("MonNomDeFichier.csv");
            }
        }]
    },
}

这会更改文件名但内容丢失。我认为fnClick函数缺少this.fnSetText,但我不知道该放入什么内容?!

1 个答案:

答案 0 :(得分:1)

尝试:

"fnClick": function ( nButton, oConfig, oFlash ) {
              oFlash.setFileName("MonNomDeFichier.csv");
              this.fnSetText( oFlash, this.fnGetTableData(oConfig) );//Add this after your code, since you have overridden the original code 
           }

点击此处了解更多信息: http://datatables.net/forums/discussion/10248/fnclick-callback-on-tabletools-flash-button-breaks-csv-xls-export