I have a jqGrid working with the SortableRows
option enabled. Previously i had been allowing rows to always be sorted. When the rows are dropped, then the database is updated via an ajax call. To do this I have been using the update
option.
Now i need to implement the sorting to NOT be allowed for certain rows. Namely those rows who have a column value of "1" for one of the visible columns. I have successfully blocked the ajax updating, but visually the row still gets dropped in the new location. I need to visually revert the row to the original location.
So far I have this code, which works, but the area with the comment is where I am stuck as to how to revert the row to the previous position.
jQuery("#all_driver_runs").jqGrid('sortableRows', {
update: function (ev, ui) {
//first check the value of the 'placed_in_runs' column
if ($('#all_driver_runs').jqGrid('getRowData', ui.item[0].id)['placed_in_run'] !== "1") { //here update the database
if (!ui.item[0].previousSibling) {
$.post("scripts/update_driver_run_sort.php", {
this_one: ui.item[0].id,
prev: 'none',
next: ui.item[0].nextSibling.id
});
} else if (!ui.item[0].nextSibling) {
$.post("scripts/update_driver_run_sort.php", {
this_one: ui.item[0].id,
prev: ui.item[0].previousSibling.id,
next: 'none'
});
} else {
$.post("scripts/update_driver_run_sort.php", {
this_one: ui.item[0].id,
prev: ui.item[0].previousSibling.id,
next: ui.item[0].nextSibling.id
});
}
} else {
/*
*no DB update, and now I need to revert to previous position here ???
*/
}
}
});