How to Update Table when Dom changes? destroy() -> init() -> crash
How to Update Table when Dom changes? destroy() -> init() -> crash
Hi,
I am trying to integrate the wonderful DataTable into a DerbyJS app. DerbyJS updates the dom live, adding and removing elements, but DataTables doesn't know that.
I initialize my table using the Dom source, and I saw that there is ajax.reload() for the Ajax data source, but there is no other reload() available. draw() only takes the table's internal data into account. Is there any way this is supposed to work?
So I thought doing this:
$('#example').DataTable().destroy(false);
$('#example').DataTable(s);
where "s" is the settings object. However, when I add or remove a tr and then call the code above, the result is an exception:
Uncaught NotFoundError: Failed to execute 'insertBefore' on 'Node': The node before which the new node is to be inserted is not a child of this node. (query.dataTables.js:9065)
line 9065 is this code:
if ( ! remove && orig ) {
// insertBefore acts like appendChild if !arg[1]
orig.insertBefore( table, settings.nTableReinsertBefore );
}
The full stacktrace is in line numbers: 7038, 8998, 6875, 9065. This is with Version 1.10.7.
Debugging this, I saw that settings.nTableReinsertBefore is a #comment element. But even if I copy the html code to live.datatables.net I am not yet able to reproduce it there. I need to debug this further, but my main question is, as I said, is this the right way to update the table?
Answers
Wow, it just takes a bit of reading the documentation :)
I found cell/s/row/s.invalidate(). Will try that for now, and if that also fails for some reason, I'll resort to modifying the table manually with the api, disabling DerbyJS updates.