JqG​​rid表单编辑-如何将不可编辑的字段发布到服务器 [英] JqGrid Form Edit - How to post non editable field to server

查看:70
本文介绍了JqG​​rid表单编辑-如何将不可编辑的字段发布到服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在jqgrid中使用表单编辑.网格具有其他不可编辑的列,这些列是可见的.在表单编辑中,这些字段不会显示,但仍需要发布到服务器.

I am using form edit in jqgrid. The grid has additional non-editable columns which are visible. On form editing, these fields are not to be shown but still need to be posted to server.

感谢您的帮助.

推荐答案

如果您需要发送有关不可编辑列的其他信息,这些列可见,我建议您使用 onclickSubmit 回调.回调可以返回对象,该对象可以用于扩展将在表单提交时发送到服务器的数据.例如以下onclickSubmit实现

If you need to send additional information about non-editable columns which are visible I would recommend you to use onclickSubmit callback. The callback can return object which can be used to extend the data which will be send to the server on form submit. For example the following onclickSubmit implementation

onclickSubmit: function () {
    return {
        test: "bla bla"
    };
}

使用参数test扩展发送到服务器的标准数据,该值将设置为字符串"bla bla".

extend the standard data sent to the server with parameter test which value will be set to the string "bla bla".

您可以为您的目的执行以下操作:

You can do for your purpose the following:

onclickSubmit: function (options, postdata) {
    var rowid = postdata[this.id + "_id"]; // like "list_id"
    return {
        myParam: $(this).jqGrid("getCell", rowid, "colName")
    };
}

其中"colName"是您要发送的列的name属性的值.

where "colName" is the value of name property of the column which you need to send.

在我看来,这种方法非常简单和灵活.

Such approach seems to me very simple and flexible enough.

这篇关于JqG​​rid表单编辑-如何将不可编辑的字段发布到服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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