Problem with fnGetDisplayNodes or fnDrawCallback
Problem with fnGetDisplayNodes or fnDrawCallback
I think there might be bug in fnDrawCallback or fnGetDisplayNodes when there are multiple tables on a page with the same definition.
I have a loop where I define n number of tables. The table definition are all the same except for the id.
[code]
var currTable = $("#table_"+id).dataTable(
...
"fnDrawCallback": function() {
if ( typeof this != 'undefined' ) { // make sure table is ready
updateMainBox(this);
}
...
});
[/code]
After each table update, I want to get the top row and print it in a box outside of the table. I use the fnDrawCallback function for this (as shown above)....the code to update this box looks like this:
[code]
function updateMainBox(currTable) {
if (currTable.fnGetDisplayNodes().length>0){
...
}
}
[/code]
This works if there's one table on a page. However, when there are more than one tables on a page the firing from the second table's fnDrawCallback throws the error "Uncaught TypeError: Cannot read property 'aiDisplay' of null" on this line of code in the fnGetDisplayNodes plugin :
[code]
if (oSettings.aiDisplay.length !== 0 ){
[/code]
Also, what's interesting is that I can call updateMainBox(currTable) from outside the fnDrawCallback on any of the tables and it works without a problem.
Any idea what could be causing this or how to work around it? Thanks!
I have a loop where I define n number of tables. The table definition are all the same except for the id.
[code]
var currTable = $("#table_"+id).dataTable(
...
"fnDrawCallback": function() {
if ( typeof this != 'undefined' ) { // make sure table is ready
updateMainBox(this);
}
...
});
[/code]
After each table update, I want to get the top row and print it in a box outside of the table. I use the fnDrawCallback function for this (as shown above)....the code to update this box looks like this:
[code]
function updateMainBox(currTable) {
if (currTable.fnGetDisplayNodes().length>0){
...
}
}
[/code]
This works if there's one table on a page. However, when there are more than one tables on a page the firing from the second table's fnDrawCallback throws the error "Uncaught TypeError: Cannot read property 'aiDisplay' of null" on this line of code in the fnGetDisplayNodes plugin :
[code]
if (oSettings.aiDisplay.length !== 0 ){
[/code]
Also, what's interesting is that I can call updateMainBox(currTable) from outside the fnDrawCallback on any of the tables and it works without a problem.
Any idea what could be causing this or how to work around it? Thanks!
This discussion has been closed.
Replies
Hmm - having said that, I see you are passing currTable into your update function - so actually it looks like you might initialise them separately? Can you post a link to an example showing this issue?
Allan