Skip to Content

Error show bound data

Hi guys,

I have a problem showing the JSON data that I read. I worked with OData models/requests and bindings, but not with JSON models/requests.

My "list" from my "Master" view is empty, at the beginning and I fill it regularly with some auto-refresh tactic.

Now the problem I have is that the data isn't shown, although the "list" list has the Model bound to it.

Here is the "list":

<List
       id="list"
       mode="{device>/listMode}"
       select="handleListSelect"
       items="{Master}" >
       <ObjectListItem
            type="{device>/listItemType}"
            press="handleListItemPress"
            title="{Material}"
            number="{TargetQ}"
            numberUnit="{UM}" >
            <attributes>
                 <ObjectAttribute text="{DelivQ}" />
            </attributes>
            <firstStatus>
                 <ObjectStatus
                      text="{Master>OrderNo}"
                      state="{path: 'OrderStatus',
                           formatter: 'sap.ui.demo.myFiori.util.Formatter.statusState'}" />
            </firstStatus>
            <secondStatus>
               <ObjectStatus
                 text="{ path: 'OrderStatus',
                      formatter: 'sap.ui.demo.myFiori.util.Formatter.statusText'}"
                 state="{ path: 'OrderStatus',
                      formatter: 'sap.ui.demo.myFiori.util.Formatter.statusState'}" />
            </secondStatus>
       </ObjectListItem>
  </List>


I've tried defining the "items" element different ways: {/Master}, {Master}, no luck.

I've tried defining the data to show different ways: {Master>OrderNo}, {OrderNo}, {Master>/OrderNo}, no luck

I've checked that the model has the data bound:

sap.ui.getCore().byId("Master").byId("list").getModel("Master").getData()[0].OrderNo
"000100765931"

So the model is bound and has 2 items but the page still shows this 😔:

Here is how I bind the data:

onOrdersSuccess : function (text) {
       var view = sap.ui.getCore().byId("Master")
       setTimeout(function() {
            //view.getModel("Master").getData().push(text);
            view.getModel("Master").setData([]); 
            view.getModel("Master").setData(text); 
            view.getModel("Master").updateBindings();
       }, 1000);
  }

Any ideas ?

Regards,

Marius

Capture.JPG (18.3 kB)
Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Best Answer
    Posted on Sep 09, 2016 at 09:53 AM

    Hi Marius,

    I am assuming that your data is all in the "Master" model.

    I am also assuming that with this:

    items="{Master}"

    You are willing to bind on the aggregation that is in the Master model.

    Since you are using a named model, EVERYTHING that is using this model has to include the name.

    So for example, every binding should be like;

    title="{Master>Material}"

    And the aggregation binding should be like:

    items="{Master>/}"

    When using a "/" you are binding to the root of the model, when not using the "/", you are binding by current context.

    So if my assumption is correct and you want to bind your items on the root of the model, use the code above. If the attribute bindings should be attributes of this same model, use the code above for that as well.

    Let us know if this fixes your problem, else we can dive deeper into it 😊

    Good luck,

    Caspar

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.