0

I want to dynamically change my exported CSV file name.

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");
            }
        }]
    },
}

This does change the file name but the content is missing. I think fnClick function is missing this.fnSetText but I don't know what to put in it ?!

Mehdiway
  • 10,337
  • 8
  • 36
  • 68

1 Answers1

1

Try:

"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 
           }

Check here for more info : http://datatables.net/forums/discussion/10248/fnclick-callback-on-tabletools-flash-button-breaks-csv-xls-export

JaskeyLam
  • 15,405
  • 21
  • 114
  • 149