Quantcast
Viewing all articles
Browse latest Browse all 82127

Question about possible fnDeleteRow bug

I have a problem which looks to me like a bug. But I'm a DataTables newbie, so am a bit unsure how it's supposed to work.

If you could confirm that my understanding of how it's supposed to work is correct, I'll put together a test case to demonstrate it.

I'm using datatables 1.9.4:
- Bootstrap v2
- data loaded via Ajax
- sorting enabled
- pagination style is 'bootstrap'

The problem I'm seeing is this: if I just wanted a read-only table, it's all working splendidly. But I have a button on each row which, when pressed, will delete the row.

The code to delete the row on the backed works fine; but I'm trying to delete the row on the client-side table, so I don't have to reload the whole table from Ajax.

I'm finding the correct row, and passing that to fnDeleteRow. And *a* row is being deleted, but not the correct one.

What I think is happening is this:

fnDeleteRow expects the row to have _DT_RowIndex set to be the index of the visible rows, whereas it's staying as the index of the rows when initially read from Ajax.

I can see from inside the debugger, that for example, the row I've selected was the 4th row returned in the Ajax data; but after sorting, it's the 6th row in the displayed table.

and _DT_RowIndex is set to 4, whereas I think it should now be set to 6.

So when this row is passed to fnDeleteRow, the displayed row 4 is deleted, not the actual row 6 selected.

If this sounds wrong (i.e. I've understood what's happened and the behaviour is incorrect, as I suspect), then I'll produce a test case.

thanks
Rachel

Viewing all articles
Browse latest Browse all 82127

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>