Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Binding problem/conflicts with equal names in JSONModel

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

Former Member
Former Member replied

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. 

0 View this answer in context

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question