jqGrid:其他编辑参数未发布到服务器 [英] jqGrid: Additional Edit Parameters not being posted to server
问题描述
我正在使用Lib.Web.MVC
助手,因此我的初始jqGrid JS由该对象生成.调用@ grid.GetJavaScript之后,然后发出一个单独的调用来修改editData
集合,如下所示.这是我正在使用的有效JS. AreaId
和AreaItemId
的值永远不会提交给控制器操作.
I'm using the Lib.Web.MVC
helper so my initial jqGrid JS is generated by that object. After the call to @grid.GetJavaScript, I then issue a separate call to modify the editData
collection as specified below. Here is the effective JS that I'm using. The values of AreaId
and AreaItemId
don't ever get submitted to the controller action.
$(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();
}
}
});
});
推荐答案
我认为您遇到问题的原因是您对navGrid
的两次呼叫,而不是一次. navGrid 方法创建导航栏.您只能在网格中创建一个一个导航栏.
I suppose that the reason of your problem are two calls of navGrid
which you do instead of one. The navGrid method creates the navigator bar. You can create only one navigator bar in the grid.
如何从该行<navGrid
代码的/a>功能测试是否存在nav
属性,该属性将通过该方法创建(请参见
How you can see from the line of code of navGrid
the function test existence of nav
property which will be crated by the method (see the line which just assign this.nav = true;
). So the code
if(this.nav) {return;}
将仅用于跳过该方法的第二次执行.
will be used just to skip the second execution of the method.
因此,要解决您的问题,您应该将两个呼叫合并为一个:
So to solve your problem you should just combine two calls in one:
...
}).jqGrid('navGrid', '#GetAreaItemDetailsPager',
{ search: false },
{ height: 175, url: '/Admin/UpdateAreaItemDetail', width: 400, recreateForm: true,
closeAfterEdit: true,
editData: {
AreaItemId: function () {
return $('#ddlAreaItems').val();
},
AreaId: function () {
return $('#ddlAreas').val();
}
}
},
{ height: 175, url: '/Admin/InsertAreaItemDetail', width: 400, recreateForm: true,
closeAfterAdd: true,
editData: {
AreaItemId: function () {
return $('#ddlAreaItems').val();
},
AreaId: function () {
return $('#ddlAreas').val();
}
}
});
如果将常用的添加"和编辑"设置设置为表单编辑的默认设置(在页面上),则可以减少代码
You can reduce the code if you would set common Add and Edit settings as default settings (on the page) for form editing
$.extend($.jgrid.edit, {
height: 175,
url: '/Admin/InsertAreaItemDetail',
width: 400,
recreateForm: true,
closeAfterAdd: true,
closeAfterEdit: true,
editData: {
AreaItemId: function () {
return $('#ddlAreaItems').val();
},
AreaId: function () {
return $('#ddlAreas').val();
}
}
});
在navGrid
调用之前
.在这种情况下,通话本身可以减少到
before calling of navGrid
. In the case the call itself can be reduced to
...
}).jqGrid('navGrid', '#GetAreaItemDetailsPager', { search: false });
这篇关于jqGrid:其他编辑参数未发布到服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!