Reputation: 13165
I have one function in controller. It will return a value. I have called that function in view using renderer:this.getController('test.controller.Barchart').change();
but it is not working. I am getting an error wind has no method getController()
. Can anybody tell me how to call it correctly?
Upvotes: 1
Views: 20405
Reputation: 620
Having a view call a controller is considered the essence of evil. The view should never be aware of the controller. I'm a lead on a large project that uses ExtJS and we don't allow anything in our views other than the JSON description of the view. The logic that is looking for a controller should likely be in the controller itself.
Upvotes: 6
Reputation: 2140
Try this: 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();
Upvotes: 0
Reputation: 3263
please refer below solution!!!
var ControllerRef=<applicationreference>.getController(<ControllerfolderPath>.controllerName);
ControllerRef.<ControllerFunction>();
Example:
var MyApp = Ext.create('Ext.app.Application', {
......
......
});
var ControllerRef = MyApp.getController('general.ManagerController');
ControllerRef.MyFunction();
Thanks
Upvotes: 5