extjs cellediting event passing activecolumn as null

327 Views Asked by At

This happens with extjs versions 6.2+. I have a cellediting plugin which has a listener event on edit. When the onEdit is called, I am trying to check the xtype of the edited cell and it fails since active columns are passed as nulls. This works fine with earlier versions. As per research, this could be a bug which never got fixed in extjs versions and don't see any workaround yet. If anybody come across this, please advise.

Problem: On cellediting, editor.activecolumn is null. It works fine with earlier versions. Looks like ExtJs 6.2 CellEditing plugin editor.el.dom always passes null.

Panel Layout :

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

Above code will trigger onEdit and below is the function:

    onEdit: function(editor, c, e) {

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

There are 1 best solutions below

0
On BEST ANSWER

Indeed, starting from ExtJS 6.2 the activeColumn property is no more available from the editor object on edit. But you shouldn't have relied on it in the first place, as it's not documented, and there are other means to achieve what you want.

Take a look at the context (second argument) that is passed to the edit event listener. Among other things, it has a column property, which is what you need. So in your case, you can replace

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

with

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

and it will work across all version of ExtJS 6.