I am new to EXTJS 4 MVC architecture . I have one function in controller which i want to call from my view. How can i call that function?
3
votes
2 Answers
0
votes
You can send a message: YourApp.fireEvent('my_event', options) and listen it inside of your controller. But it's not right.
If you're using as you're talking mvc you should not write code in view. (Note: There may be a code, for example column renderer code, not business logic). View should be just a component group. To create component event listener use control method of Ext.app.Controller.
0
votes
You can do it like so:
You can put your controller as a global variable in your app.js like so:
Ext.define('MySharedData', {
my_Controller:Object
});
In your controller:
MySharedData.my_Controller=this.getController('<ControllerfolderPath>.controllerName');
then call the function that you want, from your view:
MySharedData.my_Controller.my_Function();