on 09-09-2016 9:41 AM
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
Try this
User | Count |
---|---|
88 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
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.