on 08-17-2013 3:29 PM
Hi all
How to get access to the view controller from the js view?
I tried the followings, but didn't work
this.getControllerName()
sap.ui.getCore().byId(<viewname>).getController()
What is the correct way to get the controller.
Regards
Aakash
Hi Aakash,
1. If u want to access the controller of the same view then you can use,
oController.method_name();
2. If you want to access the controller of one view in another view then you can use,
sap.ui.controller("project_name.view_name").method_name();
Thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
In same view, You get bydefault "oController". oController return current controller of this view,If you want to access controller method use oController.method_Name()
Thanks
Manoj
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The JS view provides a hook method called createContent : function(oController) the parameter oController is the instance of controller and you can access all the methods of controller.
Thanks
Abhilash
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
You can create a global variable and assign the reference to it from createContent method.
Or as the view initialization starts from createConent method, whatever the additional methods you are writing they should be called from createContent method only, so you can pass oController reference from there only. Let us know your requirement so that we can suggest alternate approach.
Thanks
Abhilash
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.