too much recursion bug in datatables 1.8.1
too much recursion bug in datatables 1.8.1
mkoryak
Posts: 14Questions: 0Answers: 0
i created a table and set one of the mDataProps to null so that i could have custom data in the column:
[code]
var colDefs = [
{ "mDataProp": "id",
"sTitle": "ID"
},
{ "mDataProp": "note",
"sTitle":"Note",
"sClass": "editable"
},
{ "mDataProp": null,
"sTitle": "Actions",
"sClass": "actions",
"fnRender": function(obj) {
return "delete";
}
}
];
[/code]
then i created the table in an empty table tag:
[code]
var $table = $('.target-table').dataTable({
"bProcessing": false,
"bJQueryUI": true,
"sScrollY": "400px",
"sPaginationType": "full_numbers",
"aoColumns": colDefs
});
[/code]
after this, i add a new row to the table which comes from an ajax callback:
[code]
var pos = $table.fnGetPosition($($table.fnGetNodes()).filter("."+data.DT_RowClass)[0]);
$table.fnUpdate(data, pos);
[/code]
data would be:
{id:1, note:'test'}
at this point there is a too much recursion error.
the issue is with fnUpdate, at the line:
[code] else if ( typeof mData == 'object' )[/code]
mData is null, which causes the above to evaluate to true, so another call to fnUpdate is made within that if block, next time around mData is still null, and too much recursion happens.
let me know if this is a bug with datatables, or am i doing something incorrectly?
[code]
var colDefs = [
{ "mDataProp": "id",
"sTitle": "ID"
},
{ "mDataProp": "note",
"sTitle":"Note",
"sClass": "editable"
},
{ "mDataProp": null,
"sTitle": "Actions",
"sClass": "actions",
"fnRender": function(obj) {
return "delete";
}
}
];
[/code]
then i created the table in an empty table tag:
[code]
var $table = $('.target-table').dataTable({
"bProcessing": false,
"bJQueryUI": true,
"sScrollY": "400px",
"sPaginationType": "full_numbers",
"aoColumns": colDefs
});
[/code]
after this, i add a new row to the table which comes from an ajax callback:
[code]
var pos = $table.fnGetPosition($($table.fnGetNodes()).filter("."+data.DT_RowClass)[0]);
$table.fnUpdate(data, pos);
[/code]
data would be:
{id:1, note:'test'}
at this point there is a too much recursion error.
the issue is with fnUpdate, at the line:
[code] else if ( typeof mData == 'object' )[/code]
mData is null, which causes the above to evaluate to true, so another call to fnUpdate is made within that if block, next time around mData is still null, and too much recursion happens.
let me know if this is a bug with datatables, or am i doing something incorrectly?
This discussion has been closed.
Replies
Very good find - thanks for letting me know about it. Javascript and its quirks... :-). I've just committed a small change into DataTables which fixes this issue. You can get the update from the nightly version (1.8.2) available on the downloads page: http://datatables.net/download/
Regards,
Allan