row.add().draw() causes all rows to be detached
row.add().draw() causes all rows to be detached

Link to test case:
Debugger code (debug.datatables.net):
Error messages shown:
Description of problem:
Is there a way for a row to be added to the grid and rendered without all current rows to be detached?
We are using version 1.10.16.
We call row.add().draw() to add a new entry to the table, however in _fnDraw() a call to children().detach() is made. That causes focus on selected input in the grid to loos focus.
We need to be able to add a row without disturbing the existing ones (and not using paging).
Answers
You can try passing
page
intodraw()
, that should do the trick,Colin
Thanks Colin, I have tried and it doesn't make a difference. The application is not and can't use paging. Does the draw("page") only works when paging is enabled?
Please provide more details about this. Why do you need to add rows while an input is in focus? Can you hold off adding the rows until there is no focused inputs?
Kevin
A test case would be useful here. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.
Cheers,
Colin
Hi Colin,
I have added test case here:
http://live.datatables.net/zelaquvu/32/edit?html,js,output
Disable js autorun. run the js and scroll down until you don't see the input.
Then the row addition will trigger and will cause 2 issues:
1/ The grid will jump back to the top
2/ Make the input lose focus
I didn't see a jump, but yep, the
input
lost focus. One thing you could do is work out inpreDraw
which element has the focus, and then put that focus back ondraw
. It's clumsy and messy, but I can't think of any other alternative.Colin
Thank you Colin.
We have tried that approach but restoring the focus is what caused the grid to jump back to the focused cell. So if user is scrolling, a row added in the background will cause the scroll to jump.
Maybe one of the solutions in this SO thread will help. I tried one of them here:
http://live.datatables.net/zelaquvu/37/edit
Kevin