cancel
Showing results for 
Search instead for 
Did you mean: 

Error show bound data

MariusStoica
Active Participant
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

Caspar_van_t
Explorer
0 Kudos

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

MariusStoica
Active Participant
0 Kudos

Hi Caspar,

Unfortunately it doesn't work. It's how I did the things whit OData model, so what you've written only confirms what I've known, ergo the question I'm posting here on the SCN.

So, to recap (and show the modifs you suggested):

1. Yes, the model is "Master", the view is "Master"

2. The list is like this:


<List

       id="list"

       mode="{device>/listMode}"

       select="handleListSelect"

       items="{Master}" >

       <ObjectListItem

            type="{device>/listItemType}"

            press="handleListItemPress"

            title="{Master>Material}"

            number="{Master>TargetQ}"

            numberUnit="{Master>UM}" >

            <attributes>

                 <ObjectAttribute text="{Master>DelivQ}" />

            </attributes>

            <firstStatus>

            <ObjectStatus

                 text="{Master>OrderNo}"

                 state="{path: 'Master>OrderStatus',

                      formatter: 'sap.ui.demo.myFiori.util.Formatter.statusState'}" />

            </firstStatus>

            <secondStatus>

                <ObjectStatus

                      text="{ path: 'Master>OrderStatus',

                           formatter: 'sap.ui.demo.myFiori.util.Formatter.statusText'}"

                      state="{ path: 'Master>OrderStatus',

                           formatter: 'sap.ui.demo.myFiori.util.Formatter.statusState'}" />

             </secondStatus>

       </ObjectListItem>

  </List>

3. And the model data is like this (meaning, no deep structure):

And it still doesn't work

Any thoughts?

Regards,

Marius

Former Member
0 Kudos

Try this

  1. <List 
  2.        id="list" 
  3.        mode="{device>/listMode}" 
  4.        select="handleListSelect" 
  5.        items="{Master>/}" > 
  6.        <ObjectListItem  
  7.             type="{device>/listItemType}" 
  8.             press="handleListItemPress" 
  9.             title="{Material}" 
  10.             number="{TargetQ}" 
  11.             numberUnit="{UM}" > 
  12.             <attributes> 
  13.                  <ObjectAttribute text="{Master>DelivQ}" /> 
  14.             </attributes> 
  15.             <firstStatus> 
  16.             <ObjectStatus 
  17.                  text="{OrderNo}" 
  18.                  state="{path: 'Master>OrderStatus', 
  19.                       formatter: 'sap.ui.demo.myFiori.util.Formatter.statusState'}" /> 
  20.             </firstStatus> 
  21.             <secondStatus> 
  22.                 <ObjectStatus 
  23.                       text="{ path: 'Master>OrderStatus', 
  24.                            formatter: 'sap.ui.demo.myFiori.util.Formatter.statusText'}" 
  25.                       state="{ path: 'Master>OrderStatus', 
  26.                            formatter: 'sap.ui.demo.myFiori.util.Formatter.statusState'}" /> 
  27.              </secondStatus> 
  28.        </ObjectListItem> 
  29.   </List> 
MariusStoica
Active Participant
0 Kudos

Hi Robbe,

This worked:


items="{Master>/}" >

Thank you,

Marius

Former Member
0 Kudos

yw

Caspar_van_t
Explorer
0 Kudos

Hi Marius,

Thats what I said..

"And the aggregation binding should be like:

items="{Master>/}"


I'm glad we found the solution, I already thought that would be the fix.



Cheers,

Caspar

MariusStoica
Active Participant
0 Kudos

BTW Caspar,

If you have the time, could you take a look at my other post ?

The issue is similar, but I don't understand why it doesn't work.

Many thanks,

Marius

Answers (0)