0

这发生在 extjs 版本 6.2+ 上。我有一个单元编辑插件,它在编辑时有一个监听器事件。当调用 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");
    }
}
4

1 回答 1

0

事实上,从 ExtJS 6.2 开始,该activeColumn属性不再可以从edit. 但是您一开始就不应该依赖它,因为它没有记录在案,并且还有其他方法可以实现您想要的。

查看传递给事件侦听器的上下文(第二个参数)。edit除其他外,它有一个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。

于 2017-09-12T04:28:32.797 回答