mvc3 jqgrid readonly fields on edit/addform - asp.net-mvc-3

I have a jqGrid using Form Editing. I would like Some of the fields to be Readonly in 'Edit' mode but not in 'Add' mode. I have tried some of the suggestions I have found elsewhere to solve this(see example below), but still cannot get it to work!
If anyone can help I shall be most grateful!
In The below grid I am attempting to set 'LogonName' to ReadOnly in 'edit' mode, and NOT in 'Add' mode.
$('#jpgCustomers').jqGrid({
url: '#Url.Action("Customers")',
datatype: 'json',
mtype: 'POST',
colNames: ['Name', 'FullName', 'Description'],
colModel: [
{ name: 'LogonName', index: 'LogonName', align: 'left', width:80, editable:true, search:true, stype:'text',editrules:{required:true}},
{ name: 'FullName', index: 'FullName', align: 'left',width: 200, editable:true, search:true, stype:'text',editrules:{required:true}},
{ name: 'Description', index: 'Description', align: 'left', width: 300, editable:true, search:true, stype:'text'}
]
//..
$("#jpgCustomers").jqGrid('navGrid', '#jpgpCustomers',
{ add: true, del: true, edit: true, search: false},
//edit form
{ width: '500',
editCaption: 'Edit Customer',
url: '#Url.Action("EditCustomer")',
reloadAfterSubmit: true,
closeAfterEdit: true,
//always start from a new form
recreateForm: true,
beforeShowForm: function(form) {
//center the edit dialog on screen
var dlgDiv = $("#editmod" + jpgCustomers.id);
CenterDialog(dlgDiv);
$("#jpgCustomers").jqGrid('setColProp','LogonName',{editoptions: {readonly:'readonly'}});
}
},
//Add form
{ width: '500',
addCaption: 'Add Customer',
url: '#Url.Action("CreateCustomer")',
reloadAfterSubmit: true,
closeAfterEdit: true,
beforeShowForm: function(form) {
var dlgDiv = $("#editmod" + jpgCustomers.id);
CenterDialog(dlgDiv);
$("#jpgCustomers").jqGrid('setColProp','LogonName',{editoptions: {readonly:false}});
}
},
//Delete form
{ width: '250',
url: '#Url.Action("DeleteCustomer")',
beforeShowForm: function(form) {
//center the delete dialog on screen
var dlgDiv = $("#delmod" + jpgCustomers.id);
CenterDialog(dlgDiv);
//change the Delete confirmation message
var sel_id = $("#jpgCustomers").jqGrid('getGridParam','selrow')
$("td.delmsg", form).html("Delete User <b>" + $("#jpgCustomers").jqGrid('getCell', sel_id,'LogonName') + "</b>?");
}
}
);

OK, so after Hours of testing and retesting, and trying various things, I have stumbled on the solution!
I have made a couple of changes to the above code, and not Entirely sure which has been the overriding answer to the problem but here is what I did:
1) Moved The call to 'SetColProp' from the beforeShowForm into the beforeInitData function
2) put beforeInitData before beforeShowForm - I don;t think This actually makes any difference, but it works, so I'm leaving it there!
3) Included a recreateForm:true in The Add form section (I already had one in the edit section)
I think point 1 and 3 made the difference, but I couldn;'t tell you why!
Heres the working navGrid section altered from The Question:
$("#jpgCustomers").jqGrid('navGrid', '#jpgpCustomers',
{ add: true, del: true, edit: true, search: false},
//edit form
{ width: '500',
editCaption: 'Edit Customer',
url: '#Url.Action("EditCustomer")',
reloadAfterSubmit: true,
closeAfterEdit: true,
//always start from a new form
recreateForm: true,
beforeInitData: function(form) {
$("#jpgCustomers").jqGrid('setColProp','LogonName',{editoptions: {readonly:'readonly'}});
},
beforeShowForm: function(form) {
//center the edit dialog on screen
var dlgDiv = $("#editmod" + jpgCustomers.id);
CenterDialog(dlgDiv);
}
},
//Add form
{ width: '500',
addCaption: 'Add Customer',
url: '#Url.Action("CreateCustomer")',
reloadAfterSubmit: true,
closeAfterEdit: true,
recreateForm: true,
beforeInitData: function(form) {
$("#jpgCustomers").jqGrid('setColProp','LogonName',{editoptions: {readonly:false}});
},
beforeShowForm: function(form) {
var dlgDiv = $("#editmod" + jpgCustomers.id);
CenterDialog(dlgDiv);
}
},
//Delete form
{ width: '250',
url: '#Url.Action("DeleteCustomer")',
beforeShowForm: function(form) {
//center the delete dialog on screen
var dlgDiv = $("#delmod" + jpgCustomers.id);
CenterDialog(dlgDiv);
//change the Delete confirmation message
var sel_id = $("#jpgCustomers").jqGrid('getGridParam','selrow')
$("td.delmsg", form).html("Delete User <b>" + $("#jpgCustomers").jqGrid('getCell', sel_id,'LogonName') + "</b>?");
}
}
);

Related

Hide navgrid buttons depending on the number of records in jqgrid

I need to hide the delete button if there are less than 2 records in the grid. This is the js code. For some reason, the flag showDelCurrencyButton is not working out here and is always false.
Any other way to do it?
showDelCurrencyButton = false;
grid.jqGrid({
datatype: 'local',
jsonReader: jqgrid.jsonReader('CurrCd'),
mtype: 'POST',
pager: '#currencyPager',
colNames: ['Abbrev.', 'Name', 'Symbol'],
colModel: [
{
name: 'CurrCd', index: 'CurrCd', width: 200, sortable: false,
editable: true,
edittype: 'select', stype: 'select',
editrules: { required: true },
editoptions: {
dataUrl: getServerPath() + 'Ajax/GetCurrencies',
buildSelect: function (data) {
var currSelector = $("<select id='selCurr' />");
$(currSelector).append($("<option/>").val('').text('---Select Currency---'));
var currs = JSON.parse(data);
$.each(currs, function () {
var text = this.CurName;
var value = this.CurCode;
$(currSelector).append($("<option />").val(value).text(text));
});
return currSelector;
}
}
},
{ name: 'CurrName', index: 'CurrName', width: 200, sortable: false },
{ name: 'CurrSymbol', index: 'CurrSymbol', width: 200, sortable: false },
],
loadtext: 'Loading...',
caption: "Available Currencies",
scroll: true,
hidegrid: false,
height: 116,
width: 650,
rowNum: 1000,
altRows: true,
altclass: 'gridAltRowClass',
onSelectRow: webview.legalentities.billing.onCurrencySelected,
loadComplete: function (data) {
if (data.length > 1) {
showDelCurrencyButton = true;
}
var rowIds = $('#currencyGrid').jqGrid('getDataIDs');
$("#currencyGrid").jqGrid('setSelection', rowIds[0]);
},
rowNum: 1000
});
grid.jqGrid('navGrid', '#currencyPager', {
edit: false,
del: (showDelCurrencyButton == true),
deltitle: 'Delete record',
search: false,
refresh: false
}
});
Your current code uses datatype: 'local' without specifying data parameter with input data. It seems strange. In any way you can hide the Delete button dynamically identifying it by id. It's "del_" + grid[0].id in your case. Thus you can use $("#del_" + grid[0].id).hide(); to hide it. By the way one can use this instead of grid[0] inside of loadComplete.
I'd recommend you to read the old answer for more details and to read the answer, which shows how to disable/enable navigator buttons (like Delete button) instead of hiding.

jqGrid add buttons for add/edit/delete in toolbar not working

I have tried to implement the code for adding buttons in jqGrid toolbar from the example site http://www.guriddo.net/demo/bootstrap/ but I'm surprised to find that it isn't working for me. Searched for a couple of hours but I can't figure it out. Here is my code:
<script type="text/javascript">
$(function () {
var gridDataUrl = '#Url.Action("JsonCategories", "AdminNomCategory")'
var grid = $("#reportsGrid").jqGrid({
url: gridDataUrl,
datatype: "json",
mtype: 'POST',
colNames: [
'#Html.DisplayNameFor(model => model.CategoryGuid)',
'#Html.DisplayNameFor(model => model.CategoryName)',
'#Html.DisplayNameFor(model => model.CategoryDescription)'
],
colModel: [
{ name: 'CategoryGuid', index: 'CategoryGuid', width: 10, align: 'left', classes: "nts-grid-cell", hidden: true },
{ name: 'CategoryName', index: 'CategoryName', width: 10, align: 'left', classes: "nts-grid-cell" },
{ name: 'CategoryDescription', index: 'CategoryDescription', width: 10, align: 'left', classes: "nts-grid-cell" }
],
rowNum: 20,
rowList: [10, 20, 30],
height: 450,
width: 1140,
pager: '#pager', /*jQuery('#pager'),*/
sortname: 'CategoryGuid',
toolbarfilter: true,
viewrecords: true,
sortorder: "asc",
caption: "Categories",
ondblClickRow: function (rowid) {
var gsr = jQuery("#reportsGrid").jqGrid('getGridParam', 'selrow');
if (gsr) {
var CategoryGuid = grid.jqGrid('getCell', gsr, 'CategoryGuid');
window.location.href = '#Url.Action("Edit", "AdminNomCategory")/' + CategoryGuid
}
else {
alert("Please select Row");
}
},
#*onSelectRow: function (rowid) {
var gsr = jQuery("#reportsGrid").jqGrid('getGridParam', 'selrow');
if (gsr) {
var CategoryGuid = grid.jqGrid('getCell', gsr, 'CategoryGuid');
window.location.href = '#Url.Action("Edit", "AdminNomCategory")/' + CategoryGuid
}
else {
alert("Please select Row");
}
}*#
});
//jQuery("#reportsGrid").jqGrid('navGrid', '#pager', { edit: true, add: true, del: true });
var template = "<div style='margin-left:15px;'><div> Customer ID <sup>*</sup>:</div><div> {CustomerID} </div>";
template += "<div> Company Name: </div><div>{CompanyName} </div>";
template += "<div> Phone: </div><div>{Phone} </div>";
template += "<div> Postal Code: </div><div>{PostalCode} </div>";
template += "<div> City:</div><div> {City} </div>";
template += "<hr style='width:100%;'/>";
template += "<div> {sData} {cData} </div></div>";
$('#reportsGrid').navGrid('#pager',
// the buttons to appear on the toolbar of the grid
{ edit: true, add: true, del: true, search: false, refresh: false, view: false, position: "left", cloneToTop: false },
//// options for the Edit Dialog
{
editCaption: "The Edit Dialog",
template: template,
errorTextFormat: function (data) {
return 'Error: ' + data.responseText
}
},
// options for the Add Dialog
{
template: template,
errorTextFormat: function (data) {
return 'Error: ' + data.responseText
}
},
// options for the Delete Dailog
{
errorTextFormat: function (data) {
return 'Error: ' + data.responseText
}
}
);
grid.jqGrid('filterToolbar', { searchOnEnter: true, enableClear: false });
jQuery("#pager .ui-pg-selbox").closest("td").before("<td dir='ltr'>Rows per page </td>");
grid.jqGrid('setGridHeight', $(window).innerHeight() - 450);
});
$(window).resize(function () {
$('#reportsGrid').jqGrid('setGridHeight', $(window).innerHeight() - 450);
});
</script>
I am using jqGrid 4.4.4 and ASP.NET. The thing I noticed, is that on the example page, the buttons are located inside a div with an id like 'jqGridPagerLeft', but on my page, that div has no id. So I went looking inside the jqGrid source but I'm lost and I can't figure out why it doesn't have an id allocated.
Any clues? I just want to add the buttons to the bottom toolbar. Thx!

load jqgrid via ajax to dialog search options dropdown don't work

When I use my jqgrid (v.4.6) on page evrything is ok.
When I load jqgrid via ajax to jquery dialog searchoptions dropdown list doesn't work for me.
In jqgrid search box searchoptions dropdown list doesn't work for me either.
$(document).ready(function(){
jQuery("#list_bs").jqGrid({
url:'some.php',
datatype: "json",
height: 450,
width: 1050,
colNames:['FirstName','Name','Date'],
colModel:[
{name:'FirstName',index:'FirstName', width:200, sorttype:'string', searchoptions:{sopt:['bw','bn','cn','ne','ew','en']}},
{name:'Name',index:'Name', width:200, sorttype:'string', searchoptions:{sopt:['bw','bn','cn','ne','ew','en']}},
{name:'Date',index:'Date', width:100, sorttype:'string', searchoptions:{sopt:['bw','bn','cn','ne','ew','en']}},
],
rowNum:50,
rowList : [20,30,50],
loadonce:false,
multiselect : false,
mtype: "GET",
shrinkToFit: false,
rownumbers: true,
gridview: true,
pager: '#pager',
sortname: 'Name',
viewrecords: true,
sortorder: "ASC",
toolbar: [true,"top"],
});
$("#list_bs").jqGrid('navGrid', '#pager_bs',
{
edit:false,
add:false ,
del:false,
},
{},
{},
{},
{
multipleSearch: true,
showQuery: true
}
......
)
});
jQuery("#list_bs").jqGrid('filterToolbar',{ searchOperators: true,stringResult:true, searchOnEnter: false, autosearch: true ,enableClear: false});
try like below this work for me.You have give data in the dropdown in its column model
{
name: 'Name', Name: 'Title', align: 'center', editable: true, editoptions: { readonly: 'readonly' },
stype: 'select',
searchoptions: {
sopt: ['eq','cn'],
dataUrl: //get data from server
buildSelect: function (data) {
var response, s = '<select>', i;
response = jQuery.parseJSON(data);
s += '<option value="0">--Select Book Title--</option>';
if (response && response.length) {
$.each(response, function (i) {
s += '<option value="' + this.Name+ '">' + this.Name+ '</option>';
});
}
return s + '</select>';
}
}
}
I don't need dropdown in toolbar input
My search operator dropdown list doesn't open.
The problem is only when my own jqgrid is loaded by ajax in to jquery dialog.
$( "#my_dialog" ).dialog({
width:'auto',
open: function(event, ui){
$.ajax(
{
url: "some.php",
type: "POST",
data: "is_dialog=true",
error: function(){
},
beforeSend: function(){
$("#loader").show();
},
complete: function(){
$("#loader").hide();
},
success: function( strData ){
$("#dialog_content").html(strData );
}
}
);
},
});
...........
<div id="my_dialog" >
<div id="dialog_content"></div>
</div>

editParams not sent/processed when keys set to true on inline grid

),
I am having an issue with using inline editing in jqGrid. I am switching some grids from form editing to inline editing. The mechanics of the inline editing works fine, but I am trying to send additional data back to the server when I save (I used postData to do this when I was using form editing). I have set the editParams to send back additional data and this works if I edit the record by clicking the edit pencil and save by clicking the save icon in the nav bar. Howerver, I have noticed that when I set keys: true so that I can use Escape/Enter to cancel/save the record and/or if I initiate record editing by double-clicking the row, the editParams are not processed/sent to server. I think this is because the editParams are set up in the click event of the edit button - should I be leveraging this somehow?
Am I missing something? Appreciate any help in fixing my code.
Here is my grid code:
jQuery(document).ready(function() {jQuery('#grdRateEntries')
.jqGrid({
url: 'myUrl',
mtype: 'POST',
datatype: 'xml',
loadonce: false,
editurl: 'myEditUrl',
colNames: [
'ID', '', 'Type', 'Reported', 'Actual', 'Notes', 'Available', 'Paid', 'RateID'],
colModel: [
{name: 'id', index:'id', hidden:true, editable:false, key:true},
{ name: 'act', index: 'act', width: ($.browser.webkit ? 40 : 35), align: 'center', sortable: false, formatter: 'actions',
formatoptions: {
keys: false, // we want to use [Enter] key to save the row and [Esc] to cancel editing.
//delOptions: myDelOptions
delbutton: false,
editbutton: false
}
},
{name:'ddlType', index:'ddlType', width:200, editable:true, edittype:'select', editrules:{required:true}, editoptions:{label:'Type', dataInit:function(el){InitType(el);}, value:':-- Select --;' }},
{name:'ReportedUnits', index:'ReportedUnits', width:200, editable:true, editoptions:{size:10}, editrules:{number:true, required:true}},
{name:'ActualUnits', index:'ActualUnits', width:200, editable:true, editoptions:{size:10}, editrules:{number:true, required:true}},
{name:'Notes', index:'Notes', width:200, editable:true, editrules:{required:true}, editoptions:{rows:'2', cols:'30'}, edittype:'textarea'},
{name:'Available', index:'Available', edittype:'checkbox', width:100, editable:true},
{name:'Paid', index:'Paid', edittype:'checkbox', width:100, editable:false, editoptions:{size:25}},
{name:'TypeID', index:'TypeID', hidden:true, editable:false}
],
recreateForm: false,
multiselect: false,
multiboxonly: false,
pager: jQuery('#pggrdRateEntries'),
rowNum:10,
rownumbers:true,
rowList:[5, 10, 20, 50],
sortname:'Id',
sortorder:'ASC',
viewrecords:true,
grouping:false,
imgpath:'',
caption:'',
autowidth:true,
shrinktofit:false,
toolbar: [true, 'top'],
postData:{entityId:1,employeeid:24,clientid:6},
ondblClickRow: function(id)
{
if(id){ jQuery('#grdRateEntries').jqGrid('restoreRow',lastSel); jQuery('#grdRateEntries').jqGrid('editRow',id,true); lastSel=id; }
},
loadComplete: function()
{
grid.setGridHeight('auto');
grid.setGridWidth(700, false);
var iCol = GetColumnIndexByName($('#grdRateEntries'), 'act');
$(this).find('>tbody>tr.jqgrow>td:nth-child(' + (iCol + 1) + ')')
.each(function(ndx) {
$('<div>', {
title: 'Set Actual=Reported',
mouseover: function() {
$(this).addClass('ui-state-hover');
},
mouseout: function() {
$(this).removeClass('ui-state-hover');
},
click: function(e) {
var selRowId = $(this).parents('tr').attr('id'); //$('#grdRateEntries').jqGrid('getGridParam', 'selrow');
var reportedVal = $('#grdRateEntries').jqGrid('getCell', selRowId, 'ReportedUnits');
$('#grdRateEntries').jqGrid('setCell', selRowId, 'ActualUnits', reportedVal);
}
}
).css({'margin-right': '5px', float: 'left', cursor: 'pointer'})
.addClass('ui-pg-div ui-inline-custom')
.append('<span class="ui-icon ui-icon-copy"></span>')
.prependTo($(this).children('div'));
});
}
});
$('#grdRateEntries').navGrid(
'#pggrdRateEntries',
{
add: false,
edit: false,
del: true,
refresh: true,
search: false,
view: false,
edittitle: 'Edit selected record',
addtitle: 'Add new record',
deltitle: 'Delete selected record',
cloneToTop:true,
closeOnEscape:true
}, // use default settings
grdRateEntrieseditOptions,
grdRateEntriesaddOptions,
grdRateEntriesdeleteOptions, // use default settings for delete
grdRateEntriessearchOptions
);
$('#grdRateEntries').jqGrid('inlineNav',
'#pggrdRateEntries',
{
editParams: {keys: false, extraparam: {entityId:1,employeeid:24,clientid:6}}
}
);
Thanks very much for any assistance!
you have the following call back functions for inline editing. in the place of "extraparam" you can set the parameters which you want to send.
jQuery("#grid_id").jqGrid('editRow',rowid, keys, oneditfunc, successfunc, url, extraparam, aftersavefunc,errorfunc, afterrestorefunc);

jqgrid apply filter after reload?

Am using jqgrid, loading data once, sorting and filtering locally and doing a refresh after each update/insert/delete. It works fine, besides that if I am using a filter (on top of grid), the filter remains the same after refresh, but the filter is not re-applied on the newly loaded data.
I have tried to call mygrid[0].triggerToolbar() after reloading grid with trigger('reloadGrid'), but there is no effect.
Thanks for any help or pointers :-)
Code below:
var lastsel;
var mygrid;
var currentLang;
//setup grid with columns, properties, events
function initGrid(lang, productData, resellerData, resellerSearchData) {
mygrid = jQuery("#list2").jqGrid({
//data loading settings
url: '/public/Gadgets/LinkGadget/ProductLinks/' + lang,
editurl: "/public/Gadgets/LinkGadget/Edit/" + lang,
datatype: "json",
mtype: 'POST',
jsonReader: {
root: "rows",
cell: "",
page: "currpage",
//total: "totalrecords",
repeatitems: false
},
loadError: function (xhr, status, error) { alert(status + " " + error); },
//column definitions
colNames: ['Id', 'ProductId', 'Reseller Name', 'Link', 'Link Status'],
colModel: [
{ name: 'Id', index: 'Id', width: 40, sortable: false, resizable: true, editable: false, search: false, key: true, editrules: { edithidden: true }, hidden: true },
{ name: 'ProductId', index: 'ProductId', width: 190, sortable: true, sorttype: 'text', resizable: true, editable: true, search: true, stype: 'select', edittype: "select", editoptions: { value: productData }, editrules: { required: true} },
{ name: 'ResellerName', indexme: 'ResellerName', width: 190, sortable: false, sorttype: 'text', resizable: true, editable: true, search: true, stype: 'select', edittype: "select", editoptions: { value: resellerData }, editrules: { required: true }, searchoptions: { sopt: ['eq'], value: resellerSearchData} },
{ name: 'Link', index: 'Link', width: 320, sortable: true, sorttype: 'text', resizable: true, editable: true, search: true, edittype: "textarea", editoptions: { rows: "3", cols: "50" }, editrules: { required: true }, searchoptions: { sopt: ['cn']} },
{ name: 'LinkStatus', index: 'LinkStatus', width: 100, sortable: false, resizable: true, editable: false, search: false, formatter: linkStatusFormatter}],
//grid settings
//rowList: [10, 25, 50],
rowNum: 20,
pager: '#pager2',
sortname: 'ProductId',
sortorder: 'asc',
height: '100%',
viewrecords: true,
gridview: true,
loadonce: true,
viewsortcols: [false, 'vertical', true],
caption: " Product links ",
//grid events
onSelectRow: function (id) {
if (id && id !== lastsel) {
if (lastsel == "newid") {
jQuery('#list2').jqGrid('delRowData', lastsel, true);
}
else {
jQuery('#list2').jqGrid('restoreRow', lastsel);
}
jQuery('#list2').jqGrid('editRow', id, true, null, afterSave); //reload on success
lastsel = id;
}
},
gridComplete: function () {
//$("#list2").setGridParam({ datatype: 'local', page: 1 });
$("#pager2 .ui-pg-selbox").val(25); //changing the selected values triggers paging to work for some reason
}
});
//page settings
jQuery("#list2").jqGrid('navGrid', '#pager2',
{ del: false, refresh: false, search: false, add: false, edit: false }
);
//refresh grid button
jQuery("#list2").jqGrid('navButtonAdd', "#pager2", { caption: "Refresh", title: "Refresh grid", buttonicon: 'ui-icon-refresh',
onClickButton: function () {
reload();
}
});
//clear search button
jQuery("#list2").jqGrid('navButtonAdd', "#pager2", { caption: "Clear search", title: "Clear Search", buttonicon: 'ui-icon-refresh',
onClickButton: function () {
mygrid[0].clearToolbar();
}
});
//add row button
jQuery("#list2").jqGrid('navButtonAdd', '#pager2', { caption: "New", buttonicon: 'ui-icon-circle-plus',
onClickButton: function (id) {
var datarow = { Id: "newid", ProductId: "", ResellerName: "", Link: "" };
jQuery('#list2').jqGrid('restoreRow', lastsel); //if editing other row, cancel this
lastsel = "newid"; // id;
var su = jQuery("#list2").addRowData(lastsel, datarow, "first");
if (su) {
jQuery('#list2').jqGrid('editRow', lastsel, true, null, afterSave); //reload on success
jQuery("#list2").setSelection(lastsel, true);
}
},
title: "New row"
});
//delete row button
jQuery("#list2").jqGrid('navButtonAdd', "#pager2", { caption: "Delete", title: "Delete row", buttonicon: 'ui-icon-circle-minus',
onClickButton: function () {
if (lastsel) {
if (confirm('Are you sure you want to delete this row?')) {
var url = '/public/Gadgets/LinkGadget/Edit/' + currentLang;
var data = { oper: 'del', id: lastsel };
$.post(url, data, function (data, textStatus, XMLHttpRequest) {
reload();
});
lastsel = null;
}
else {
jQuery("#list2").resetSelection();
}
}
else {
alert("No row selected to delete.");
}
}
});
jQuery("#list2").jqGrid('filterToolbar');
}
//Used by initGrid - formats link status column by adding button
function linkStatusFormatter(cellvalue, options, rowObject) {
if (rowObject.Id != "newrow")
return "<input style='height:22px;width:90px;' type='button' " + "value='Check link' " + "onclick=\"CheckLink(this, '" + rowObject.Id + "'); \" />";
else
return "";
}
//Used by initGrid - reloads grid
function reload() {
//jqgrid setting "loadonce: true" will reset datatype from json to local after grid has loaded. "datatype: local"
// does not allow server reloads, therefore datatype is reset before trying to reload grid
$("#list2").setGridParam({ datatype: 'json' }).trigger('reloadGrid');
//mygrid[0].clearToolbar();
lastsel = null;
//Comments: after reload, toolbar filter is not applied to refreshed data. Tried row below without luck
//mygrid[0].triggerToolbar();
}
//after successful save, reload grid and deselect row
function afterSave() {
reload();
}
Your data is not getting re binded to the grid after save/update delete

Resources