I made the inline edit true for jqGrid by using below code -
if (rowid) {
if (rowid !== lastsel) {
$("#prjectForecastData").jqGrid('restoreRow', lastsel);
$("#prjectForecastData").jqGrid('editRow', rowid, true);
lastsel = rowid;
} else {
$("#prjectForecastData").jqGrid('restoreRow', lastsel);
lastsel = "";
}
}
But here in below code, while saving row, I want to make an ajax call in order to save that row in database. and also want to make that row non editable.
Right now 'clientArray'
is used to save the value on browser temporarily.But unable to make it non editable after that.
$("#saveForecastEditData").click(function(){
$("#prjectForecastData").jqGrid('saveRow',lastsel, false, 'clientArray');
jQuery('#prjectForecastData').editRow(lastsel,false);
});
So how to make an ajax call and make the row non editable after saving the row in DB successfully?
To make row non-editable you should add
not-editable-row
class to the corresponding row. The exact code can depend on jqGrid configuration which you use. For example you can just add the lineafter the line with
saveRow
, but sorting or paging of local data will recreate the grid body and so it will remove any previously set classes or rows of the grid. To make the information persistent you can save it in localdata
together with the main data. For example you can do the followingThe code of
"#prjectForecastData"
grid can userowattr
:It will restore the class
"not-editable-row"
on rows which was modified locally.To get all modified rows and to send there to the server one can use the following code
The exact parameters of
$.ajax
request will depend on your server code which get the data.In the way you will save all modified data using one ajax call. Alternativaly you can just use another (server based)
url
in the call ofsaveRow
. In the case the data of one saved row will be automatically send to the server on in the format described in the documentation.