Set PDF filename on click of the PDF TableTools button?

Set PDF filename on click of the PDF TableTools button?

NympheasiNympheasi Posts: 24Questions: 0Answers: 0
edited November 2011 in TableTools
Hi,

I would like to know if it's possible to set the pdf filename title onclick of the pdf TableTools button (the sFileName parameter)?

I would like to use dynamic filename.

Thanks!

Replies

  • NympheasiNympheasi Posts: 24Questions: 0Answers: 0
    I will need some help on this one... Where does the fileName is set and how I can change it manually via teh TableTools settings?
  • NympheasiNympheasi Posts: 24Questions: 0Answers: 0
    Don't worry, I just found it:

    [code]
    "fnClick": function( nButton, oConfig, flash ) {
    fileName = setFileName()+".pdf";
    flash.setFileName( fileName );
    this.fnSetText( flash,
    "title:"+ this.fnGetTitle(oConfig) +"\n"+
    "message:"+ oConfig.sPdfMessage +"\n"+
    "colWidth:"+ this.fnCalcColRatios(oConfig) +"\n"+
    "orientation:"+ oConfig.sPdfOrientation +"\n"+
    "size:"+ oConfig.sPdfSize +"\n"+
    "--/TableToolsOpts--\n" +
    this.fnGetTableData(oConfig)
    );
    }
    [/code]

    I set the filename I want using an external function I wrote called setfileName.
    [code]
    function setFileName(){
    var market = $("#market option:selected").text();
    var startDate = $("#from").val();
    var endDate = $("#to").val();
    var oSettings = oTable.fnSettings();
    var fileName = market+"_"+startDate+"_to_"+endDate;
    return fileName;
    }
    [/code]

    So, using the fnClick function, I set my filename (fileName = setFileName()+".pdf";) and then tell the flash the sFileName (flash.setFileName( fileName ); )

    And that's it!
This discussion has been closed.