1

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?

1
  • 1
    YOU_APP_NAME.app.getController('MyController') Commented Apr 30, 2013 at 10:45

3 Answers 3

6

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Since I learning/working with ExtJS not that long ago I've a question. How do you handle view listener events without calling controller? Say I have a grid, and I want to execute a controller function on row select event? How do you do that without calling controller from view listener?
5

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

2 Comments

whether i need to create instance MyApp in view? am getting MYApp is not defined
it's not exactly MyApp reference, but reference to View that has this controller set. In my application I call LoginBtn.click of LoginWin with this code: Ext.ComponentManager.get('LoginWin').getController().onLoginClick(); while MyApp is another window.
0

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();

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.