Getting "oConfig.fnInit is undefined" error when trying to load table with table tools

Getting "oConfig.fnInit is undefined" error when trying to load table with table tools

cipherouscipherous Posts: 4Questions: 0Answers: 0
edited December 2011 in TableTools
Hi

It seems that in my table when I initialize the datatable with

"sDom": 'T<"clear">lfrtip'

it seems to throw ""oConfig.fnInit is undefined".

However, if I remove the "T" from the sDom parameter, the table initializes just fine. Which pretty much nullifies the usage of table tools for me. Is there something I am missing? I have sSwfPath defined and oTableTools.sSwfPath defined as well.

This is with Datatables 1.8.2 and Jquery 1.6.3

Replies

  • cipherouscipherous Posts: 4Questions: 0Answers: 0
    I used firebug to trace the problem,

    it seems that TableTools.Buttons has "fnInit": null defined for the flash specific functions. Somehow, null gets translated to undefined when doing
    [code]buttonDef = $.extend( {}, TableTools.BUTTONS[ buttonSet[i] ], true );[/code]


    the error is throw when

    [code]this._fnFlashConfig( nButton, oConfig ); [/code]


    the following line fails within the method

    [code]
    if ( oConfig.fnInit !== null )
    {
    oConfig.fnInit.call( this, nButton, oConfig );
    }
    [/code]

    oConfig.fninit is actually undefined as opposed to null.
  • allanallan Posts: 63,679Questions: 1Answers: 10,498 Site admin
    Interesting! I would have expected this basic example (http://datatables.net/release-datatables/extras/TableTools/index.html) to also fail in null was being converted to undefined.

    I've just tried this on the console:

    [code]
    var o = { a: null };
    var v = $.extend( {}, o );
    [/code]

    and v.a is null rather than undefined. So I'm not to sure what is happening here.

    Allan
  • cipherouscipherous Posts: 4Questions: 0Answers: 0
    edited December 2011
    It maybe due to the version of Jquery and its implementation of $.extends then

    Also,

    wouldn't it be better to cover both cases by doing
    [code]
    if (! (oConfig.fnInit)) {
    }
    [/code]

    hmmm..according to my research, this bug with extends should've been fixed 4 years ago!

    http://bugs.jquery.com/ticket/2600

    It also looks like the example you provided fails on my system, so it must be the jquery lib that I am using.
  • cipherouscipherous Posts: 4Questions: 0Answers: 0
    aaaaand it was an older version of jquery. Sorry, working with legacy systems can be a pain.

    thanks for your time Allan and great job with the plugin!
  • allanallan Posts: 63,679Questions: 1Answers: 10,498 Site admin
    Heh - no worries. And yep - it might indeed be better to just doing if (variable) rather than checking explicitly for null. I'll keep it in mind for future!

    Allan
This discussion has been closed.