Marco
Marco

Reputation: 1334

Extjs 4.1 remove element from combox after loading

I've an MVC panel with a combobox and I'would remove some elements from the combobox after his store (local or remote) has completed to load.

the combo is declared in the view of this panel as follow:

{
            xtype:'combo',
            name: 'type',
            editable: false,
            //a local simple store with two field: 'valueType' and 'text'
            store : Ext.create('AM.store.custompropview.propertyType'),
            valueField : 'valueType',
            fieldLabel: 'combo'
}

I've tried in the controller to control the event 'afterrender' or 'boxready' and in the function to remove some element from the store, but it don't work at all.

  'combo[name="type"]' : {
            boxready:function(th, width, height, eOpts ){

                th.store.removeAt(0);
                th.store.removeAt(0);
                th.store.removeAt(0);

                }

How i can do it?

thank you

Upvotes: 1

Views: 3159

Answers (1)

Behrad Farsi
Behrad Farsi

Reputation: 1110

I think you should remove your item after store is loaded not just after your combo is rendered so you can code this in controller's init function:

Ext.getStore('AM.store.custompropview.propertyType').on('load', function(store){
store.removeAt(0);
});

Upvotes: 2

Related Questions