Sencha Touch 2-如何从视图中的商店中删除控制器中的所有()?

Sencha Touch 2-How to removeAll() in a controller from a store in a view?

我想在我的控制器中使用 stores 的 removeAll() 函数,删除 view.Is 中的 store 的内容可以吗? 这是我的代码:

我的看法:

Ext.define('demoapp.view.MainMenu',{
extend:'Ext.form.Panel',
requires:['Ext.TitleBar','demoapp.store.CCAA'],
alias:'widget.mainmenuview',
config:{
    layout:{
        type:'fit'
    },
    items:[{
        xtype:'fieldset',
        items:[{
            xtype:'titlebar',
            title:'Menú principal',
            docked:'top',
            items:[{
                xtype:'button',
                text:'Desconectar',
                itemId:'logOffButton',
                align:'right'
            }]
        },
        {
            xtype:'fieldset',
            items:[{
                xtype:'selectfield',
                itemId:'CCAAcombo',
                label:'Comunidad Autonoma',
                store:'storeCCAA',
                displayField:'nombre',
                valueField:'id',
                autoSelect:false,
                placeHolder:'Elige una para filtrar'
            }]
        }
        ]
    }],
    listeners:[{
        delegate:'#logOffButton',
        event:'tap',
        fn:'onLogOffButtonTap'
    },
    {
        delegate:'#CCAAcombo',
        event:'change',
        fn:'onCCAAcomboChange'
    }]
},
onLogOffButtonTap:function(){
    this.fireEvent('onSignOffCommand');
},
onCCAAcomboChange:function(field,value){
    console.log("ESTOY EN LA VISTA");
    var idCCAA=value;
    console.log(idCCAA);
    this.fireEvent('onCCAAcomboChangeAction',idCCAA);
}
});

我的控制器:

Ext.define('demoapp.controller.MainMenu',{
extend:'Ext.app.Controller',
config:{
    refs:{
        loginView:'loginview',
        mainMenuView:'mainmenuview'
    },
    control:{
        mainMenuView:{
            onSignOffCommand:'onSignOffCommand',
            onCCAAcomboChangeAction:'onCCAAcomboChangeAction'
        }
    }
},

//Transicion
getSlideRightTransition: function () {
    return { type: 'slide', direction: 'right' };
},

//Funciones
onSignOffCommand:function(){
    var me=this;

    Ext.Viewport.animateActiveItem(this.getLoginView(),this.getSlideRightTransition());

},
onCCAAcomboChangeAction:function(idCCAA){
    console.log("ESTOY EN EL CONTROLADOR");
    console.log(idCCAA);
}
});

在控制器中,在 onSignOffCommand:function() 中的 var me=this 行之后,我想使用视图的 store:'storeCCAA' 的 removeall() 函数。

为控制器中的选择字段添加一个refs

Ext.define('demoapp.controller.MainMenu',{
    extend:'Ext.app.Controller',
    config:{
        refs:{
            loginView:'loginview',
            mainMenuView:'mainmenuview',
            mainMenuViewSelectField: 'mainmenuview selectfield#CCAAcombo'
        },
        control:{
            mainMenuView:{
                onSignOffCommand:'onSignOffCommand',
                onCCAAcomboChangeAction:'onCCAAcomboChangeAction'
            }
        }
    },

    //Transicion
    getSlideRightTransition: function () {
        return { type: 'slide', direction: 'right' };
    },

    //Funciones
    onSignOffCommand:function(){
        var me=this;

        // Get the store of select field and remove the records
        this.getMainMenuViewSelectField().getStore().removeAll();
        Ext.Viewport.animateActiveItem(this.getLoginView(),this.getSlideRightTransition());

    },
    onCCAAcomboChangeAction:function(idCCAA){
        console.log("ESTOY EN EL CONTROLADOR");
        console.log(idCCAA);
    }
});