gpt4 book ai didi

asp.net - jqgrid编辑网址: controller action parameters

转载 作者:行者123 更新时间:2023-12-01 00:16:43 24 4
gpt4 key购买 nike

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

网格代码:

$("#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"
});

Controller 代码:

public ActionResult SaveCustomLanguageData()
{
}

最佳答案

jqGrid 向 Controller 发送命名参数,其名称与您在 colModel 的“name”属性中定义的名称相同。此外还将发送 oper=addid=_empty。因此您的 Controller 操作如下所示

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)];
}
});

关于asp.net - jqgrid编辑网址: controller action parameters,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4076834/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com