on 04-24-2015 3:08 PM
Hi all,
I am having an issue accessing elements that are located in views different by the one of the control that I am using.
In order to explain better this is the code.
var oList = this.getView().byId("list");
var items = oList.getItems();
var oList = sap.ui.getCore().byId("list");
var items = oList.getItems();
The error that I receive is:
Cannot read property 'getItems' of undefined
Thanks in advance for your help.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Alessandro Garofalo wrote:
Hi all,
I am having an issue accessing elements that are located in views different by the one of the control that I am using.
In order to explain better this is the code.
- This code works, when I am inside the controllor of the view that contains the list:
var oList = this.getView().byId("list");
var items = oList.getItems();
- This code doesn't work becasue I am trying to get the items from a list that is in a different view.
var oList = sap.ui.getCore().byId("list");
Just below it write console.log(oList);
here perhaps you will not get the data.
if you look into the View's byId-method, you can see that it prepends the views Id, it essentially calls sap.ui.getCore().byId(this.createId(id)).
This is so that you can instantiate a view several times without having duplicate IDs. In order to access the Controls from the outside, you either need the View so you can call view.byId(id), or you have to manually concatenate the view's id with the id like this: sap.ui.getCore().byId(viewId + "--" + id).
Follow this link for refrence.
sapui5 - sap.ui.getCore().byId() returns no element - Stack Overflow
Regards
Dhananjay
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Alessandro,
Is it possible for you to give more information like sequence of calling both views?
As per my understanding your "list" is not initialized by the time you are calling in a different view.
Thanks.
Thanks.
Sarath.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
85 | |
10 | |
10 | |
9 | |
7 | |
6 | |
5 | |
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.