too much recursion bug in datatables 1.8.1

too much recursion bug in datatables 1.8.1

mkoryakmkoryak Posts: 14Questions: 0Answers: 0
edited August 2011 in Bug reports
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?

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Hi mkoryak,

    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
  • mkoryakmkoryak Posts: 14Questions: 0Answers: 0
    Allan, thanks for the quick response and fix!
This discussion has been closed.