最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - jQGrid, how to make a column editable in the add dialog but not during (inline) edits - Stack Overflow

programmeradmin8浏览0评论

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?

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).

Example of dialog based column enable/disable:
.htm

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?

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).

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

Share Improve this question edited Jan 1, 2011 at 14:59 Oleg 222k35 gold badges412 silver badges812 bronze badges asked Nov 29, 2010 at 19:13 DavidDavid 831 gold badge1 silver badge4 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 18

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

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

You can see this live here.

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.

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论