Select created row using serverside
Select created row using serverside
Hi,
I want the created row to get selected after creation.
editor.on('postCreate', function (e, json, data, id) {
console.log(id)
table.row('#row_' + id).select();
});
This works with serverside false. Is there a way to get it work with serverside true?
The row id is printed in console but not selected.
This question has an accepted answers - jump to answer
Answers
With server-side processing you need to wait for the next
draw
event:The reason for that is that the row isn't in the table or document until the draw happens which is async with server-side processing enabled.
Allan
Wonderful, thanks!
One more thing I need to check with you regarding this,
Everything works with the above code except when using scroller plugin, and the user has scrolled down enough to make datatables fetch another "page" of data.
If the user at that stage press NEW the selected row will not get selected after submitted.
I guess a conflict occurs with the draw events. Do you have any suggestions on how to tackle that?
It won't get selected because it doesn't exist on the client-side (it is outside of the paging). What makes this particularly difficult is that we don't know where in the paging the new row will appear since it is user data based and the sorting presumably can put it anywhere. Another call to the server would be needed to determine the paging position - redraw the table to that position (which with SSP is another call to the server) and then select it.
I don't see an easy way to address this I'm afraid.
Allan
Ok, I understand, thank you