发送ASP.Net文本框的值来保存的jqGrid事件 [英] Sending Value of ASP.Net textbox to Jqgrid save event

查看:78
本文介绍了发送ASP.Net文本框的值来保存的jqGrid事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个asp.net的形式,上面有一个jqGrid的。用户可以在主窗体上输入账号,然后输入一些数据到jqGrid的。

在点用户在网格中保存的行,我也想对面的形式通过账号来保存P​​ROC,因为我们用它来制定出网格线一些折扣信息。

我不知道如何在节省点将此信息传递翻过?

更新

我使用JSON作为我的数据类型,使用内联编辑和使用editurl张贴电网与它保存到后端数据库交易的Web服务。

更新2 - 解决方案

这是code我已经习惯了一个文本框的值与正常后数据一起传递给

 的jQuery(网格).jqGrid('inlineNav,#pager,{编辑:假的,补充:真,德尔:假的,搜索:假的,                //添加额外参数到后调用
                addParams:{
                    useDefValues​​:真实,
                    addRowParams:{
                        键:真实,
                        aftersavefunc:reloadGrid,
                        extraparam:{ACCNO:getAccNumber,colourName:getColName}
                    }
                },
                editParams:{
                    键:真实,
                    aftersavefunc:reloadGrid,
                    extraparam:{ACCNO:getAccNumber,colourName:getColName}
                }
            });

该函数获取asp.net文本框的值

  //获取账号字段的值
            getAccNumber =功能(){
                返回$(#&下;%= txtAccNo.ClientID%gt;中)。VAL();
            };


解决方案

您可以使用 editRow extraparam 选项

  onSelectRow:功能(ID){
    ...
    $(本).jqGrid('editRow,身份证,{
        键:真实,
        网址:yourServerUrl
        extraparam:{
            使用accountNumber:功能(){
                返回$(#accountNr)VAL();
            }
        }
    });
    ....
}

其他参数使用accountNumber 从id为输入字段的当前值=accountNr将被额外发送到标准数据。

您可以看到这里相应的演示。因为没有URL正在 http://www.ok-soft-gmbh.com/jqGrid/myServerUrl 中存在一个会得到一个错误,而是一个可以在提琴手容易验证,萤火虫或在IE或Chrome的开发者工具的附加参数使用accountNumber 将真正发送到服务器。

在ASP.NET code的情况下,你可能会需要使用像语法<%= accountNumber.ClientID%GT;获得编号的形式的相应的输入字段

一个可以使用的或者 inlineData 的jqGrid与性能选项定义方法。这里的想法是一样的描述这里 POSTDATA 。在答案,你会发现其中使用 inlineData 的例子。

I have got an asp.net form, with a jqgrid on it. The user can enter an account number on a main form, and then enter some data onto a jqgrid.

At the point the user saves the row in the grid, i would also like to pass the account number across from the form to the save proc, as we use this to work out some discount info for the lines in the grid.

I'm not sure how at the point of saving to pass this information accross?

UPDATE

I'm using json as my datatype, using inline editing and using editurl to post the grid to a web service that deals with saving it to a back end database.

UPDATE 2 - Solution

This is the code i have used to pass the value of a text box to along with the normal post data

jQuery(grid).jqGrid('inlineNav', "#pager", { edit: false, add: true, del: false, search: false,

                //add the extra params to the post call
                addParams: {
                    useDefValues: true,
                    addRowParams: {
                        keys: true,
                        aftersavefunc: reloadGrid,
                        extraparam: { accNo: getAccNumber, colourName: getColName }
                    }
                },
                editParams: {
                    keys: true,
                    aftersavefunc: reloadGrid,
                    extraparam: { accNo: getAccNumber, colourName: getColName }
                }
            });

This function gets the value of the asp.net text box

//get the value of the account number field
            getAccNumber = function () {
                return $("#<%= txtAccNo.ClientID %>").val();
            };

解决方案

You can use extraparam option of editRow:

onSelectRow: function (id) {
    ...
    $(this).jqGrid('editRow', id, {
        keys: true,
        url: "yourServerUrl",
        extraparam: {
            accountNumber: function () {
                return $("#accountNr").val();
            }
        }
    });
    ....
}

Additional parameter accountNumber with the current value from the input field with id="accountNr" will be sent additionally to the standard data.

You can see here the corresponding demo. Because no URL are exist under http://www.ok-soft-gmbh.com/jqGrid/myServerUrl one will get an error, but one can easy verify in the Fiddler, Firebug or in Developer Tools of IE or Chrome that additional parameter accountNumber will be really send to the server.

In case of ASP.NET code you could be needed to use the syntax like "<%=accountNumber.ClientID%>" to get id of the corresponding input field of the form.

One can use alternatively inlineData option of jqGrid with properties defined as methods. The idea here is the same as described here for postData. In the answer you will find an example where inlineData are used.

这篇关于发送ASP.Net文本框的值来保存的jqGrid事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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