jqGrid的editurl:控制器操作参数 [英] jqgrid editurl : controller action parameters

查看:1500
本文介绍了jqGrid的editurl:控制器操作参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在使用的jqGrid属性editurl后,我打提交关于增加一个新行按钮控制器动作被调用。但是,我怎么得到的所有网格行吗?其中参数应该从我的控制器的操作方法,以获得电网数据读取?

格code:

  $(#list1的)。jqGrid的({
            网址:'/ CMS / GetCustomLanguageData',
---
---
editurl:'/ CMS / SaveCustomLanguageData
---

添加新行code:

  grid.jqGrid('editGridRow,新,{身高:280,reloadAfterSubmit:假的,addCaption:添加记录,
    editCaption:编辑记录,
    bSubmit:提交,
    bCancel:取消,
    BCLOSE:关闭,
    SAVEDATA:数据已更改保存更改!?
    再见:是的,
    BNO:否
});

控制器code:

 公众的ActionResult SaveCustomLanguageData()
{
}


解决方案

的jqGrid发送到与该名称命名的参数控制器作为你的名称属性定义 colModel 。此外将发送 OPER =添加 ID = _empty 。所以,你的控制器动作可以像下面

 公共JsonResult SaveCustomLanguageData(串号,串OPER,为MyObject项)
{
    //测试ID为_empty或oper为增加。
    //如果是这样添加的项目,并返回新的ID值
    //例如返回JSON(123);
}

在客户端,你应该去code例如具有以下code

JSON响应

  jQuery.extend(jQuery.jgrid.edit,{
    afterSubmit:功能(响应,POSTDATA){
        返回[真,,jQuery.parseJSON(response.responseText)];
    }
});

When I use editurl property in my jqgrid, the controller action gets called after I hit submit button on adding a new row. But how do I get all the grid rows there? Which parameter should I read from my controller action method in order to get the grid data?

Grid code:

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

Add new row code:

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 code:

public ActionResult SaveCustomLanguageData()
{
}

解决方案

jqGrid send to the controller named parameters with the name as you defined in the 'name' property of the colModel. Additionally will be send oper=add and id=_empty. So your controller action can look like following

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

on the client side you should decode the JSON response for example with the following code

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

这篇关于jqGrid的editurl:控制器操作参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆