extjs cellediting 事件将 activecolumn 传递为 null

extjs cellediting event passing activecolumn as null

Extjs 版本 6.2+ 会发生这种情况。我有一个 cellediting 插件,它在编辑时有一个侦听器事件。调用 onEdit 时,我试图检查已编辑单元格的 xtype,但它失败了,因为活动列作为空值传递。这适用于早期版本。根据研究,这可能是一个错误,在 extjs 版本中从未得到修复,也没有看到任何解决方法。如果有人遇到这个,请指教。

问题:在编辑单元格时,editor.activecolumn 为空。它适用于早期版本。看起来 ExtJs 6.2 CellEditing 插件 editor.el.dom 总是传递 null。

面板布局:

    hideHeaders: false,
sortableColumns: false,
rowLines: true,
collapsible: false,
titleCollapse: true,
layout: 'auto',
title: 'Test Page',
selModel: 'cellmodel',
plugins: {
    ptype: 'cellediting',
    clicksToEdit: 1,
    listeners: {
        beforeedit: 'isEditable',
        edit: 'onEdit'
    }
}

上面的代码会触发onEdit,下面是函数:

    onEdit: function(editor, c, e) {

    // combobox check
    if (editor.activeColumn.config.editor.xtype === 'combo') {
                 console.log("it's combo");
    }
}

确实,从 ExtJS 6.2 开始,activeColumn 属性 不再可用于 edit 上的编辑器对象。但是你一开始就不应该依赖它,因为它没有记录,还有其他方法可以实现你想要的。

查看传递给 edit 事件侦听器的 context(第二个参数)。除其他外,它还有一个 column 属性,这正是您所需要的。所以在你的情况下,你可以替换

onEdit: function(editor, c, e) {
    if (editor.activeColumn.config.editor.xtype === 'combo') {
         console.log("it's combo");
    }
}

onEdit: function(editor, context) {
    if (context.column.config.editor.xtype === 'combo') {
         console.log("it's combo");
    }
}

它适用于所有版本的 ExtJS 6。