how to extend a button click event and call it base click event

how to extend a button click event and call it base click event

ofirofir Posts: 6Questions: 3Answers: 0

Hi all, I saw on the documentation how to extend a button:
my problem is that I want to do something before the click event and than call the original click event that will generate my pdf file.

var tableTools = new $.fn.dataTable.TableTools( oTableDayTrading, {
"aButtons": [
{ "sExtends":"pdf", "fnClick":
function ( nButton, oConfig, oFlash ) {
doSomething();
//call the original function that generates the pdf file
)...

Answers

  • ofirofir Posts: 6Questions: 3Answers: 0
    edited May 2015

    OK, I was able to overcome this by adding the following:

    { "sExtends":"pdf", "fnClick":function (nButton, oConfig, flash ) { /*-----------------works----------------------------- * 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)); ------------------doesn't works------------------------------*/ var that = this; getReportData(productTypes.dayTrading,function(response) { renderDayTrading(extendItems(response.dayTrading)); that.fnSetText( flash,"title:"+ that.fnGetTitle(oConfig) +"\n"+ "message:"+ oConfig.sPdfMessage +"\n"+ "colWidth:"+ that.fnCalcColRatios(oConfig) +"\n"+ "orientation:"+ oConfig.sPdfOrientation +"\n"+ "size:"+ oConfig.sPdfSize +"\n"+ "--/TableToolsOpts--\n" +that.fnGetTableData(oConfig)); }); /*------------------doesn't works------------------------------*/ } },

    but now I'm getting:

    "this.movie.clearText is not a function" on tableTools.js.
    if I'm removing the fnClick extension the this.movie.clearText is defined and working. any idea on how to work it out?

This discussion has been closed.