2
votes

I have a grid, the rows of which can be clicked on. The click fires an event that is then captured by the controller. Is there a way for that controller to open a popup and call a controller to populate that popup with its associated view? This is what I have in my grid's controller now:

init: function() {
    ...
    this.control({
        'shipmentsgrid': {
            itemrowclick: this.itemRowClick
        }
    })
},
itemRowClick: function() {
    var win = new Ext.Window({var win = new Ext.Window({
        items: [{
            xtype: 'shipmentmonthly' // This is not recognized
        }]
    }).show();
}
1

1 Answers

2
votes

I am not quite sure what you trying to archive. But you can easily fetch a instance of another controller using getController('YourControllerName') called from any controller scope. That will present you with a instance of this controller (and even load necessary classes). Now you are free to call any method on this controller with any arguments. For example you may also either provide the instance of this controller as argument and us that one as scope with or use this (But that depends on your implementation)

For your example:

itemRowClick: function() {
    var ctrl = this.getController('Controller2');
    var win = ctrl.openWin();
    win.show();
}

// resident in controller 2

openWin: function() {
    var win = Ext.create('Ext.window.Window',{
        items: [{
            xtype: 'shipmentmonthly' // This is not recognized
        }]
    });
    return win;
}