1
votes

I have two controllers like this:

Controller 1(MAIN)

Ext.define('App.MainController', {
    extend: 'Ext.app.Controller',
    models:[
        //some_models
    ],
    stores:[
        //some_stores
    ],
    views: [
        //some_views
    ],
    refs: [],
    init: function() {
        this.TipoDetalle='';
        this.control({
            'GridConcursos':{
                itemdblclick:this.onDblClickRow
            }
        });
    },

    //some_code

    onDblClickRow:function(element, record, item, index, e, eOpts){
        this.TipoDetalle=record.data['tipo_concurso'];
    }

    //some_code
});

Controller 2(SUB CONTROLLER)

Ext.define('App.SubController', {
    extend: 'App.MainController',
    models:[
        //some_models
    ],
    stores:[
        //some_stores
    ],
    views: [
        //some_views
    ],
    refs: [],
    init: function() {
        this.control({
            'FichaDetalle':{
                beforeshow:this.onBeforeShow
            }
        });
    },

    //some code

    onBeforeShow:function(){
        //Some way to print the variable TipoDetalle from the main controller
    }
});

On the second controller,in the function onBeforeShow I want to print or show the variable from the first controller TipoDetalle,but I don´t know if it is possible,and if it is possible I don´t know how to get the variable in the second controller

1

1 Answers

2
votes

You can use this syntax:

<appname>.app.getController(<controller's full name>).<var name>

in your case it would be

App.app.getController('App.MainController').TipoDetalle

Make sure you initialize TipoDetalle variable in controller like below:

Ext.define('App.MainController', { extend: 'Ext.app.Controller', TipoDetalle:'', ...