Complete Delete of row when using RowReorder?
Complete Delete of row when using RowReorder?
ChakronSA
Posts: 4Questions: 1Answers: 0
I have a table that has rowReorder enabled. Users also need to be able to delete a row from that table. I'm having trouble fully deleting a row. Example:
https://jsfiddle.net/ChakronSA/c45eL717/
To recreate:
- Click "Delete" next to "Name 3". This deletes the row and updates the order labels.
- Drag "Name 4" so it's above "Name 1". This works, but now the labels are wrong (should show 1, 2, 4, 4). I assume this happens because rowReorder still thinks the "Name 3" row is there.
How do I make the underlying storage aware that a row within the rowReorder object has been removed? Thanks!
This discussion has been closed.
Replies
The issue is here:
DataTables doesn't know that you have done it - and it continues to use its cached data.
You could possibly invalidate the rows (
rows().invalidate()
) to re-read from the data source (the DOM in this case): https://jsfiddle.net/c45eL717/1/ . Or usecell().data()
rather than jQuery / DOM to update the data.Allan
Allan, thanks a lot for the help. I figured it was something like that but I was having difficulty invalidating the rows (apparently it was that simple)! The number rows in my table will always be small and what you've posted in the jsfiddle will work.
Only if you know how ;-).
Good to hear that will work for you.
Allan