我想动态更改导出的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
,但我不知道该放入什么内容?!
答案 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
}