fnUpdate moves updated row !
fnUpdate moves updated row !
Hi
I'm selecting a row and then opening a popup window, I'm using the 'uID' assigned to the row to receive details from a database and then populating a form.
When the form is saved I'm updating the row using the following:
$('#form').dataTable().fnUpdate([name] ,$('tr#' + uID)[0], 0 );
$('#form').dataTable().fnUpdate([ID] ,$('tr#' + uID)[0], 1 );
$('#form').dataTable().fnUpdate([staff] ,$('tr#' + uID)[0], 2 );
This all works fine, but sometimes when the row is updated it moves up the table.
eg: I select row 5. Click update and it moved to be between rows one and two.
No data is lost, but why does it move ? is there any way to update it and leave in the same position is started in ?
Thanks
Answers
Typical...seconds after posting that I found this :
stackoverflow.com/questions/25681591/after-selecting-a-row-in-data-table-it-goes-to-top
looks like adding **false **as the fourth value should solve it.
$('#form').dataTable().fnUpdate([name] ,$('tr#' + uID)[0], 0, false );
The legacy fnUpdate method (
row().data()
andcell().data()
are the now preferred methods) will automatically redraw the table, meaning that it will take into account any change in sorting data, so the row might be moved if the data in it causes it to be positioned differently in the sorted data structure.Allan