Remove() on hidden rows
Remove() on hidden rows
Hello all,
I'm using datatables to store information about a objects location. The information is updated every 10 seconds. The problem appears when the datatable is filtered (e.g. user is searching by name) and the table is showing just a subset of rows or even no rows.
I can identify the rows I want to update (by remove than add a new row) using table.row('[id=' + feature.uid + ']') but when I try to delete those rows with table.row(row).remove().draw(); nothing is happening. If the rows are not visible I cannot update/remove.
Any ideas would be appreciated.
Regards,
Bogdan
Replies
Can you link to a page showing the problem please?
What is
row
in the above?Allan
Hi Allan,
I cannot link to a page, sorry! In order to delete the rows i select the rows that have a class I've added on fnRowCallback event.
Works very well if the rows I want to delete are visible. Same result even if I try to delete them directly:
tableAis.rows(rows).remove().draw();
A screenshot with the actual table: http://imgur.com/Qnz4l6e
Bogdan.
That is the problem since it only selects rows which are int he DOM, but DataTables removes elements which aren't needed for the current display.
I think a lot more succinct way of doing the above is simply:
Allan
It works but than after few rounds i get on remove().draw()
TypeError: a is null
...,h=a.length;while(h--)(f=g[h])&&(a[h]=!(b[h]=f))}):function(a,e,f){return b[0]=a...
In IE 10:
Unable to get property 'nodeType' of undefined or null reference
File: jquery.min.js, Line: 2, Column: 23372
Bogdan.
Can it be the case that i add records that are not visible and than i try to remove/update them?
Bogdan
I'm not sure what would cause that I'm afraid. Unfortunately I really would need a way to reproduce that error to be able to debug it as I don't know what would cause it.
Allan
Ok, I will try to prepare a sample to reproduce the error.
Bogdan
Hi Allan
I prepared an example:
Bogdan
You have deferred rendering enabled. Therefore the row node (and the cells) haven't been created and the selector cannot operate on them.
Additionally, you are using fnRowCallback to add the class and ID. It is called only when the cell is drawn - which is not in your above use case.
The "fix" is to not enable deferred rendering and to use
createdRow
: http://live.datatables.net/wehelise/1/editAllan
Thank you for the solution!
Bogdan.