加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

asp.net – jqgrid editurl:控制器动作参数

发布时间:2020-12-15 23:56:32 所属栏目:asp.Net 来源:网络整理
导读:当我在jqgrid中使用editurl属性时,在我添加新行时点击提交按钮后会调用控制器操作.但是如何在那里获得所有网格行?我应该从控制器操作方法中读取哪个参数才能获取网格数据? 网格代码: $("#list1").jqGrid({ url: '/CMS/GetCustomLanguageData',------ edit
当我在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 = add和id = _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)];
    }
});

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读