Dojo增强网格:如何使特定单元格可编辑而不是整列

wwwo4jvm  于 2022-12-16  发布在  Dojo
关注(0)|答案(1)|浏览(196)

假设网格有10行,我想让单元格(第2列字段的第9行)可编辑,你能给予我一些解决办法吗?
这是我的网格

var grid = new dojox.grid.EnhancedGrid({
    store: store,
    autoWidth: true,
    structure: [
        { name: "Number", field: "col1", width: "84px", editable: false},
        { name: "Description", field: "col2", width: "84px", editable: false },
        { name: "Stock", field: "col3", width: "84px", editable: false }
    ]
}, "grid");
tf7tbtn2

tf7tbtn21#

尝试使用如下的canEdit函数。2下面的例子展示了如何不使第一个单元格不可编辑。

var grid = new dojox.grid.EnhancedGrid({
    store: store,
    autoWidth: true,
    structure: [
        { name: "Number", field: "col1", width: "84px", editable: false},
        { name: "Description", field: "col2", width: "84px", editable: false },
        { name: "Stock", field: "col3", width: "84px", editable: false }
    ],
 canEdit: function (inCell, inRowIndex) {
            if (inRowIndex && inCell.index === 0) {
                return false;
            }
            return this._canEdit;
        }
}, "grid");

相关问题