Javascript 添加其他参数以在使用模态表单添加新行时使用 jqGrid 发布数据
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6184399/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Add additional param to post data using jqGrid when adding new row with modal form
提问by Teneff
I need to add additional dynamic parameter to jqGrid's POST
data when I'm adding new record with modal form.
POST
当我使用模态形式添加新记录时,我需要向 jqGrid 的数据添加额外的动态参数。
I tried:
我试过:
$('#table').setPostData({group: id});
$('#table').setPostDataItem('group', id);
$('#table').setGridParam('group', id);
and nothing worked out.
并没有解决。
回答by Oleg
you can use editDataparameter of the editGridRowmethod. In the most cases you use editGridRownot directly, but using Navigator. In the case you can define editDataas the part of prmEdit
or prmAdd
of the navGrid:
您可以使用editGridRow方法的editData参数。在大多数情况下,您不是直接使用editGridRow,而是使用 Navigator。在这种情况下,你可以定义editData作为的一部分或在的navGrid:prmEdit
prmAdd
$('#table').jqGrid('navGrid','#pager',
{/*navGrid options*/},
{/*Edit options*/
editData: {
group: function() {
return id;
}
}
}
});
One more option is the serializeEditData, onclickSubmitor beforeSubmitmethod. See details hereand here.
另一种选择是serializeEditData、onclickSubmit或beforeSubmit方法。在此处和此处查看详细信息。
回答by Abdul Basit
You can add additional dynamic parameter to jqGrid's POST data
您可以向 jqGrid 的 POST 数据添加额外的动态参数
$j("#listsg11").jqGrid({
url: "/summary_reports",
postData: {department:"value1", score_r1:"value2", designation:"value3" },
mtype: 'POST',
datatype: "xml",
height: 250,
width: '100%', .... and so on
This method appends values with default params (used by jqGrid) with call.
此方法通过调用附加具有默认参数(由 jqGrid 使用)的值。