我正在使用Lib.Web.MVC
帮助程序,所以我的初始 jqGrid JS 是由该对象生成的。在调用@grid.GetJavaScript 之后,我发出一个单独的调用来修改editData
集合,如下所示。这是我正在使用的有效 JS。AreaId
和的值AreaItemId
永远不会提交给控制器操作。
$(document).ready(function () {
$('#GetAreaItemDetails').jqGrid({
colNames: ['Code', 'Name', 'Description', 'Has Addl Comments'],
colModel: [
{ editable: true, editoptions: { "maxlength": 16 }, editrules: { required: true },
name: 'AreaItemDetailCode'
},
{ editable: true, editoptions: { "maxlength": 32 }, editrules: { required: true },
name: 'AreaItemDetailName'
},
{ editable: true, editoptions: { "maxlength": 128 }, editrules: { required: true },
name: 'AreaItemDetailDescription'
},
{ editable: true, edittype: 'checkbox', editrules: { required: true },
name: 'HasAdditionalComments'
}],
caption: 'Area Item Details',
url: '/Admin/GetAreaItemDetails',
datatype: 'json',
footerrow: true,
jsonReader: { repeatitems: false, id: 'Id', subgrid: { repeatitems: false} },
mtype: 'POST',
pager: '#GetAreaItemDetailsPager',
prmNames: { npage: 'npage' },
rowList: [10, 20, 30, 40, 50],
rowNum: 10,
sortname: 'AreaItemDetailId',
viewrecords: true,
height: '100%'
}).jqGrid('navGrid', '#GetAreaItemDetailsPager',
{ search: false },
{ height: 175, url: '/Admin/UpdateAreaItemDetail', width: 400, recreateForm: true,
closeAfterEdit: true
},
{ height: 175, url: '/Admin/InsertAreaItemDetail', width: 400, recreateForm: true,
closeAfterAdd: true
});
$("#GetAreaItemDetails").jqGrid('navGrid', '#GetAreaItemDetailsPager',
{/*navGrid options*/},
{
editData: {
AreaItemId: function () {
return $('#ddlAreaItems').val();
},
AreaId: function () {
return $('#ddlAreas').val();
}
}
},
{
editData: {
AreaItemId: function () {
return $('#ddlAreaItems').val();
},
AreaId: function () {
return $('#ddlAreas').val();
}
}
});
});