BUG: FixedColumns breaks when using a remote language file (oLanguage.sUrl) in the datatables

BUG: FixedColumns breaks when using a remote language file (oLanguage.sUrl) in the datatables

jkallmanjkallman Posts: 2Questions: 0Answers: 0
edited August 2011 in General
So I know that the language file loads properly on all other tables without issue. The problem is when it is enabled on a table which also is using FixedColumns. I am using FixedColumns vs. 2.0.1 with DataTables 1.8.1

I get the following error in Chrome: "Uncaught TypeError: Cannot read property 'parentNode' of undefined". The error originates around line 522 of my FixedColumns.js file and the offending line of code is "this.dom.grid.dt.parentNode.insertBefore( nSWrapper, this.dom.grid.dt );" So somehow the property "dt" of "this.dom.grid" has not been set properly.

Here's my code for the table:
[code]

var dtSettings = {};

// ... A ton of other settings that don't matter ... //

dtSettings.oLanguage = {};
dtSettings.oLanguage.sUrl = site_url + 'themes/default/js/language/' + ec.settings.lang + '/datatables_lang.js';

// GO DATATABLES!!
var tableObj = {};
tableObj.full = EC.table.dataTable(dtSettings);

// Go FixedColumns!!!
var fixed_col = 3;
tableObj.oFC = new FixedColumns( tableObj.full, {
"iLeftColumns": fixed_col,
"iLeftWidth": 450, // pixels
"sLeftWidth": 'fixed'
});
[/code]

Replies

  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin
    You need to put your FixedColumns initialisation into fnInitComplete ( http://datatables.net/ref#fnInitComplete ) since the language loader is asynchronous.

    Allan
  • jkallmanjkallman Posts: 2Questions: 0Answers: 0
    Thank you so much Allan! Works like a charm!
This discussion has been closed.