Search code examples
javascriptextjsextjs4

ExtJS 4 remove item from store


I want to delete the first item of the store:

My store code:

Ext.define('Test.store.filtros.strEstadosMtoOrganismos', {
extend: 'Ext.data.Store',
model:  'Test.model.filtros.mdlEstadosMtoOrganismos',
autoLoad: false,
proxy: {
    type: 'ajax',
    api: {read: 'some url'},
    reader: {
                type: 'json',
                root: 'data',
                totalProperty: 'total',
                successProperty: 'success'
    }
}
});

My combo code:

xtype: 'combo',
                id: 'tfecomboEstados',
                fieldLabel :'Estado',
                queryMode: 'local',
                editable: false,
                displayField: 'label',
                valueField: 'value',
                store: 'filtros.strEstadosMtoOrganismos',
                anchor: '95%'

Code of my controller:

init:function(){
this.control({
'viewFichaMtoOrganismos #tfecomboEstados':{
            beforerender:this.onCargarEstadoFicha
        });
},
onCargarEstadoFicha:function(){
    Ext.getCmp('tfecomboEstados').getStore().removeAt(0);
}

I want to delete the first item of the store.I use the store for two combos,in one I want all the records,but in the second one I want all but the first. And removeAt(0) is not working.


Solution

  • You cannot just remove record from store to affect one combo and do not another. you need different stores for your combos.

    also use parameter in your listener function instead of getting it by getCmp function

    onCargarEstadoFicha:function(combo){ combo.getStore().removeAt(0); }