jQGrid,如何在添加对话框中使列可编辑,但在(​​内联)编辑期间不可编辑 [英] jQGrid, how to make a column editable in the add dialog but not during (inline) edits

查看:157
本文介绍了jQGrid,如何在添加对话框中使列可编辑,但在(​​内联)编辑期间不可编辑的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有列的jQGrid,我只想在添加新行时进行编辑。

I have a jQGrid with a column that I only want to be editable when adding a new row.

我看过编辑时如何执行此操作的示例和添加都发生在一个对话框中,但有没有办法用内联编辑?

I've seen examples of how to do this when edits and adds are both happening in a dialog but is there a way to do this with in-line editing?

我尝试在beforeShowForm中使用grid.setColProp(): ,但这不起作用(列保持只读,并且在添加对话框中不存在)。

I've tried using grid.setColProp() in beforeShowForm:, but this doesn't work ( the column remains read only and is not present in the add dialog).

基于对话框的列启用/禁用示例:

http://www.ok-soft-gmbh.com/jqGrid /CustomFormEdit.htm

Example of dialog based column enable/disable:
http://www.ok-soft-gmbh.com/jqGrid/CustomFormEdit.htm

推荐答案

因为您使用了旧答案中的示例(this 这个)我觉得我守ld也回答你的问题。

Because you use the example from my old answers (this and this) I feel that I should answer also on your question.

旧示例所有字段(可在添加或编辑对话框中修改)具有属性 editable:true 。应该仅在添加对话框中显示的字段将隐藏在 beforeShowForm 事件句柄。以同样的方式,我们可以临时在调用editRow方法之前将某些字段切换为 editable:false 并重置回 editable:true 在通话结束后立即:

In the old example all fields, which can be modified during Add or Edit dialogs, has property editable:true. The fields which should be shown only in the Add dialog will be made hidden inside of beforeShowForm event handle. In the same way we can temporary switch some fields to editable:false before call of the editRow method and reset back to the editable:true immediately after the call:

onSelectRow: function(id) {
    if (id && id !== lastSel) {
        grid.jqGrid('restoreRow',lastSel);
        var cm = grid.jqGrid('getColProp','Name');
        cm.editable = false;
        grid.jqGrid('editRow', id, true, null, null, 'clientArray');
        cm.editable = true;
        lastSel = id;
    }
}

你可以看到这个此处

更新: 免费jqGrid 允许定义可编辑作为回调函数。请参阅维基文章。它允许使列在某些行中可编辑,并对其他行保持不可编辑。

UPDATE: Free jqGrid allows to define editable as callback function. See the wiki article. It allows to make the column editable in some rows and holding non-editable for other rows.

这篇关于jQGrid,如何在添加对话框中使列可编辑,但在(​​内联)编辑期间不可编辑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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