To delete row from the grid you can use delRowData, but the usage of delGridRow is also possible after some tricks. In the answer I posted the demo which shows how implement local form editing. The main idea of the solution is to use processing: true
setting. You can delete local data with respect of delGridRow
by adding additional options $("#dagbok_grid").jqGrid("delGridRow", rowid, delSettings)
where the delSettings
one can define as following:
var delSettings = {
afterShowForm: function ($form) {
var form = $form.parent()[0], dialog;
// delete button: "#dData", cancel button: "#eData"
$("#dData", form).attr("tabindex", "1000");
$("#eData", form).attr("tabindex", "1001");
setTimeout(function () {
// set "Delete" button as default, so one can
// confirm deliting by pressing "Enter" key
$("#dData", form).focus();
}, 50);
dialog = $form.parent().parent();
dialog.position({
my: "center",
//at: 'center center',
of: grid.closest('div.ui-jqgrid')
});
},
// because I use "local" data I don't want to send the changes to the server
// so I use "processing:true" setting and delete the row manually in onclickSubmit
onclickSubmit: function (options) {
var gridId = $(options.gbox).attr("id").substr(5),
gridIdSelector = $.jgrid.jqID(gridId),
$grid = $("#" + gridIdSelector);
p = $grid[0].p, // jqGrid parameters
newPage = p.page,
rowids = p.multiselect ? p.selarrrow : [p.selrow];
// reset the value of processing option to true
// because the value can be changed by jqGrid
options.processing = true;
// delete the row
$.each(rowids, function () {
$grid.jqGrid('delRowData', this);
});
$.jgrid.hideModal("#delmod" + gridIdSelector,
{ gb: options.gbox,
jqm: options.jqModal,
onClose: options.onClose });
if (p.lastpage > 1) {// on the multipage grid reload the grid
if (p.reccount === 0 && newPage === p.lastpage) {
// if after deliting there are no rows on the current page
// which is the last page of the grid
newPage -= 1; // go to the previous page
}
// reload grid to make the row from the next page visable.
$grid.trigger("reloadGrid", [{page: newPage}]);
}
return true;
},
processing: true
};
I would warn you about the problems in the batch modifications of data which you get from the server. The problem which you can have is the concurrency error. In other words if two persons edit the same information. The user can first load the information and edit the information much later without refreshing grid from the server. In the time another user can modify part of the information. Detection of such errors is not so easy, but even more complex to create good error message. If the user will have to make all the modifications one more time it will make the user of your program very angry. See here and here for more information.