jqgrid editurl:控制器动作参数

当我在jqgrid中使用editurl属性时,在我添加新行时点击提交按钮后会调用控制器操作。 但是如何在那里获得所有网格行? 我应该从控制器操作方法中读取哪个参数才能获取网格数据?

网格代码:

$("#list1").jqGrid({ url: '/CMS/GetCustomLanguageData', --- --- editurl: '/CMS/SaveCustomLanguageData' --- 

添加新的行代码:

 grid.jqGrid('editGridRow',"new",{height:280,reloadAfterSubmit:false,addCaption: "Add Record", editCaption: "Edit Record", bSubmit: "Submit", bCancel: "Cancel", bClose: "Close", saveData: "Data has been changed! Save changes?", bYes : "Yes", bNo : "No" }); 

控制器代码:

 public ActionResult SaveCustomLanguageData() { } 

jqGrid使用您在colModel的’name’属性中定义的名称向控制器发送名为parameters的参数。 另外将发送oper=addid=_empty 。 所以你的控制器动作可能如下所示

 public JsonResult SaveCustomLanguageData (string id, string oper, MyObject item) { // test id for "_empty" or oper for "add". // If so add the item and return the value of the new id // for example return Json ("123"); } 

在客户端,您应该使用以下代码解码JSON响应

 jQuery.extend(jQuery.jgrid.edit, { afterSubmit: function (response, postdata) { return [true, "", jQuery.parseJSON(response.responseText)]; } });