fnDeleteRow #51

churib opened this Issue Mar 2, 2012 · 5 comments


None yet
2 participants

churib commented Mar 2, 2012

There is problem when fnDeleteRow is called simultaneously:

var rows = tableTools.fnGetSelected();
for ( iterate over rows ) {
table.fnDeleteRow( row );

The problem is caused by using _DT_RowIndex in fnDeleteRow.

churib commented Mar 2, 2012

Update: The problem presumably caused by a race condition:
The deleting of rows and updating of row-indices are happening at the same time.

My example above was bad, because it is not apparent that the fnDeleteRow was called from the ajax-call (jquery async ajax).


DataTables commented Mar 2, 2012

I think I might need a little bit more information for this one - for example are you using server-side processing? Can you use the debugger to give me a trace of your table state please: http://debug.datatables.net ?

It does sound like there would be potential for a bug here because of the async nature the draw when using server-side processing, but if you are using server-side processing then:

  1. fnDeleteRow won't do any good since it is client-side only and it doesn't know (and can't know) about your server environment.
  2. You would want to pass in false as the second parameter to stop the delete doing a redraw on every delete, which would be very expensive.

churib commented Mar 6, 2012

Currently I have a lot work to do and since I am new to JS, debugging could take a bit of time, I have to defer it. But here is the stripped down code I am using which causes the problem: https://gist.github.com/1984690


DataTables commented Mar 6, 2012

Thanks for the gist - I'm really surprised that doesn't work. I can't see any reason why it wouldn't. DataTables (as far as I can tell in my testing) is doing the right thing when deleting rows with fnDeleteRow - the data index is updated for the reference rows.

One thing to note is that you need to deleted the rows from TableTools after you have done the delete, since it currently doesn't know that DataTables has deleted a row, and thus must remove the row selection. An event for this that TableTools can hook onto might be the best thing for this.

Might that be the issue? It works the first time for you, but not the second time?


DataTables commented May 17, 2013

No feedback, and fnDeleteRow is now being effectively replaced by row.remove() so going to close.

DataTables closed this May 17, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment