balkon_smoke
balkon_smoke

Reputation: 1196

ExtJS 4: Change data in combobox (celleditor)

I'm using Ext.form.field.Combobox as cell editors in grid panel:

product: {
    xtype         : "anypartfiltercombobox",
    id            : "product-editor",
    store         : new Ext.data.Store({
        model: "Product",
        data: APP.feedbacks.aUserProducts
    }),
    displayField  : "name",
    valueField    : "id",
    queryMode     : "local",
    emptyText     : "Select game",
    allowBlank    : false,
    forceSelection: true,
    listeners     : {
        select: this._onProductChanged
    }
},
device: {
    xtype         : "anypartfiltercombobox",
    id            : "device-editor",
    store         : Ext.create("stores.Devices", {
        storeId: "device-editor-store",
        data   : APP.feedbacks.aProductDevices
    }),
    displayField  : "name",
    valueField    : "id",
    queryMode     : "local",
    emptyText     : "Select device",
    allowBlank    : false,
    autoRender    : true,
    forceSelection: true
}

In stores.Devices store I have a method loadByProduct() that should be used by changing value in product editor.

So source of this._onProductChanged is:

_onProductChanged = function(oField)
{
    var iProductId = +oField.getValue(),
    oDevicesEditor = Ext.getCmp("device-editor");

    oDevicesEditor.store.loadByProduct(iProductId);
    // Ext.StoresManager.lookUp("device-editor-sore").loadByProduct(iProductId);
}

So when I change product-editor value first (device-editor wasn't activated yet) in _onProductChanged I've got undefined for Ext.getCmp("device-editor").

But if device-editor was already opened, and then I change a product than all works correctly.

Btw, I also tried to get store using StoresManager and new data loads but in this case store contains new values and combobox shows old items.

Can anybody help me with solution?

Thanks, Andrey.

Upvotes: 0

Views: 1294

Answers (1)

Krzysztof
Krzysztof

Reputation: 16140

Try to use Ext.grid.column.Column.getEditor method instead of finding editor by id. This method should create editor if it is not created yet.

Upvotes: 1

Related Questions