kapd
kapd

Reputation: 659

ExtJS Dynamically add event handler to Column Editor

I want to dynamically add an event handler to column editor on load. It is before any data is populated in the grid. I am not able to find 'on' method on the column's editor property(column.editor.on) like i find on normal combo box. I am using latest ExtJS 6 version . I have defined the column like

    {
        xtype: "gridcolumn",
        text: "Available?",
        draggable: false,
        lockable: false,
        hideable: false,
        dataIndex: "Availablility",
        editor: {
            xtype: "combobox",
            forceSelection: true,
            typeAhead: true,
            store: [["Y","Yes"],["N","No"],["U","Not known"]],
            queryMode: "local",
        }
    }

Am I doing something wrong here? I assume that editor combobox is initialized later when we have data and we try to edit on the grid. But I want to set some events dynamically on the load of grid. Is there a way to do so?

Update: The 'on' method becomes available when we try to edit a row but it is not available on initial load of grid. Isn't there a way to temporarily initialize editing plugin to attach event handler before the data loads?

Upvotes: 1

Views: 2045

Answers (1)

Sergey Novikov
Sergey Novikov

Reputation: 4196

I can offer you two solutions:

  1. Add event handlers via listeners config of your editor (actually Ext.util.Observable.on is alias for Ext.util.Observable.addListener and listeners property use addListeners).

    A config object containing one or more event handlers to be added to this object during initialization. This should be a valid listeners config object as specified in the addListener example for attaching multiple handlers at once.

  2. Listen for this combos events in your controller, like

    'myGrid combo[name=myCombo]': { change: this.myHandler }

Upvotes: 1

Related Questions