Post 为什么不是';我的jqGrid是否传递其他表单数据?

Post 为什么不是';我的jqGrid是否传递其他表单数据?,post,jqgrid,controller,asp.net-mvc-4,Post,Jqgrid,Controller,Asp.net Mvc 4,我将ASP.NETMVC4与jqGrid一起使用,并且我试图在jqGrid添加/编辑记录时将表单中的附加值传递到Add和Edit控制器方法中。我的jqGrid如下所示: $('#jqgRulesSetupVariablesList').jqGrid({ data: JSON.stringify(("#GroupDDL").valueOf()), contentType: 'application/json; charset=utf-8', //url from wich

我将ASP.NETMVC4与jqGrid一起使用,并且我试图在jqGrid添加/编辑记录时将表单中的附加值传递到Add和Edit控制器方法中。我的jqGrid如下所示:

$('#jqgRulesSetupVariablesList').jqGrid({
    data: JSON.stringify(("#GroupDDL").valueOf()),
    contentType: 'application/json; charset=utf-8',
    //url from wich data should be requested
    url: '@Url.Action("GetRulesSetupVariables")',
    ondblClickRow: function (rowid) {
    jQuery(this).jqGrid('editGridRow', rowid,
        { url: '@Url.Action("UpdateRulesSetupVariable")', recreateForm: true, closeAfterEdit: true, closeOnEscape: true, reloadAfterSubmit: false });
    },
    //type of data
    datatype: 'json',
    //url access method type
    mtype: 'POST',
    //columns names
    colNames: ['ID', 'Name', 'Description', 'Type'],
    //columns model
    colModel: [
        { name: 'ID', index: 'ID', align: 'left', width: '30px', editable: false, key: true },
        { name: 'Name', index: 'Name', align: 'left', width: '100px', editable: true, edittype: 'text', editoptions: { maxlength: 20 }, editrules: { required: true } },
        { name: 'Description', index: 'Description', align: 'left', width: '260px', editable: true, edittype: 'text', editoptions: { maxlength: 80 }, editrules: { required: true } },
        { name: 'Type', index: 'Type', align: 'left', width: '25px', editable: true, edittype: 'text', editoptions: { maxlength: 1 }, editrules: { required: true } },
    ],
    //pager for grid
    pager: $('#jqgRulesSetupVariablesPaging'),
    //number of rows per page
    rowNum: 10,
    //initial sorting column
    sortname: 'Name',
    //initial sorting direction
    sortorder: 'asc',
    //we want to display total records count
    viewrecords: true,
    //grid height
    height: 230,
    width: 450,
});

$('#jqgRulesSetupVariablesList').jqGrid('navGrid', '#jqgRulesSetupVariablesPaging',
    { add: true, del: false, edit: true, search: false },
    // Edit Options
    { url: '@Url.Action("UpdateRulesSetupVariable")', closeAfterEdit: true, closeOnEscape: true, editData: { GroupName: function () { return "ABC"; } } },
    // Add Options
    { url: '@Url.Action("InsertRulesSetupVariable")', closeAfterAdd: true, closeOnEscape: true, editData: { GroupName: function () { return "ABC"; } } },
    // Delete options
    {}
);
我的控制器是:

[AcceptVerbs(HttpVerbs.Post)]
public ActionResult UpdateRulesSetupVariable(RulesSetupVariableViewModel viewModel, string GroupName)
{
    bool updateSuccess = UpdateRulesSetupVariable_Internal(viewModel);

    return Json(updateSuccess);
}

[AcceptVerbs(HttpVerbs.Post)]
public ActionResult InsertRulesSetupVariable(RulesSetupVariableViewModel viewModel, string GroupName)
{
    bool updateSuccess = UpdateRulesSetupVariable_Internal(viewModel);

    return Json(updateSuccess);
}
我的模型是:

public class RulesSetupVariableViewModel
{
    public int ID { get; set; }
    public string Name { get; set; }
    public string Description { get; set; }
    public string Type { get; set; }
}
ID、名称、描述和类型都很好,但GroupName却不是


你知道我做错了什么吗?

我知道了。愚蠢的错误。我正在使用双击来编辑行。我修改了这行

jQuery(this).jqGrid('editGridRow', rowid,
    { url: '@Url.Action("UpdateRulesSetupVariable")', 
      recreateForm: true, 
      closeAfterEdit: true, 
      closeOnEscape: true, 
      reloadAfterSubmit: false });
},
为此:

jQuery(this).jqGrid('editGridRow', rowid,
    { url: '@Url.Action("UpdateRulesSetupVariable")', 
      recreateForm: true, 
      closeAfterEdit: true, 
      closeOnEscape: true, 
      reloadAfterSubmit: false,
      editData: { GroupName: function () { return $("#GroupDDL").val(); } } 
},
这解决了我的问题