on 10-20-2015 4:34 PM
Hi,
i got a JSONModel (named as "MyModel") with data like this:
{
"id": 1,
"title": "Entry title",
"subData": [
{
"id": 123,
"title": "Title of my first sub data"
},
{
"id": 456,
"title": "Title of my second sub data"
}
]
}
I set the model to my component and now I want to display the data of my model in my XML view including the data under "subData" like this:
...
<ObjectAttribute text="{MyModel/title}" title="Title"/>
...
<VBox xmlns="sap.m" items="{MyModel>/subData}">
<Button text="{MyModel>title}"></Button>
</VBox>
...
For the button data binding I use {MyModel>title} as of I read this in an article I found and no other combination I tried worked.
But as you would expect it always displays "Entry title" as of the same attribute exists already in my model.
If I rename the title attribute of "subData" like for example "subTitle" the correct content is displayed.
But I think this can't be the solution ....
So any idea / advice how to set the binding correctly?
Thank you and kind regards,
Dominik
You're binding path is correct and there is no way for a conflict. You should be getting button text as "Entry Title" only if the binding path is "{MyModel>/title}" (Absolute path). I guess you're xml view could have been cached when you were trying diff combinations. Just confirm with the source of the xml view from the Network response.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yeah, thanks! 😃
That really was the problem! Now I'm on an other computer and suddenly it works!
I've tried a lot combinations and caching can definitely be the reason.
But in general:
Am I right that "MyModel>title" is just temporary at this moment (during loop)?
Is this and all possibilities (static behaviour, behaviour in loops, etc.) of binding conventions clearly documented somewhere?
That would be great.
But this topic is now solved for me!
Thanks for the help!
Dominik
Am I right that "MyModel>title" is just temporary at this moment (during loop)?
I'm not sure what you mean by temporary. When the aggregation binding happens, the binding path of the buttons will be resolved to,
1st btn - MyModel>/subData/0/title
2nd btn- MyModel>/subData/1/title
You can make use of the UI5 diagnostics tools (ctlr + Alt+ Shift + s) to view the controls binding paths info during the runtime.
I thought about "MyModel>title" is like a "temporary" variable in which the loop sets the data of "MyModel>/subData/0/title" and "MyModel>/subData/1/title".
But that's not correct. Maybe that's the thinking when coming from ABAP
But after reading a bit more (thanks for the document!!) and thinking about it, it makes more sense if you ignore the (a bit confusing) "MyModel>" for a moment. Then its clear that the binding loops over the "/subData" array and sets the current element as binding. And then what's left are the attributes of the current object like "title" (without the "/") because "/" is for absolute binding.
Following lines of the document made this clear:
So now it's clear for me!
Thank you and kind regards,
Dominik
Hi Dominik,
Not sure, whether this is what you are expecting? JS Bin - Collaborative JavaScript Debugging
Regards,
Sai Vellanki.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
80 | |
24 | |
11 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.