on 06-28-2016 12:59 PM
Hey guys,
I want to use only XML to bind some data in a .json file withe a list.
Here is my code:
XML View:
<List headerText="Positions" items="{/Positions}">
<ObjectListItem title="{positions>id}"/>
</List>
index.html
var oPositionsModel = new sap.ui.model.json.JSONModel();
oPositionsModel.loadData("model/Positions.json");
sap.ui.getCore().setModel(oPositionsModel);
model/Positions.json
{ "Positions": [
{ "id": 123456, "article": "Abcde", "amount": 12 },
{ "id": 654321, "article": "Edcba", "amount": 21 }
] }
I can't see, what's wrong. But I get "no data" all the time. There is nothing in the console saying there is a problem here.
I hope you can help
please see here the answer of nistv4n
http://stackoverflow.com/questions/38117137/sapui5-bindingproblem
And my conlusion:
1. use Component models for View crossed stuff (defined in the Manifest or in the Component.js)
2. use View models for one View stuff
3. don't use Core Models because some other App might use also a Core Model
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Michael,
I tried your code and it works fine for me: Plunker
If still not working for you, try something like this:
onInit: function(){
var oModel = new sap.ui.model.json.JSONModel();
oModel.loadData("model/Positions.json");
oModel.attachRequestCompleted(function(oEvent){
sap.ui.getCore().setModel(oEvent.getSource());
})
}
Regards,
Sai.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes, this attribute is in my bootstrap script.
<script id="sap-ui-bootstrap" | |
src="../../resources/sap-ui-core.js" | |
data-sap-ui-libs="sap.m,sap.ui.layout" | |
data-sap-ui-theme="sap_bluecrystal" | |
data-sap-ui-compatVersion="edge" | |
data-sap-ui-xx-bindingSyntax="complex" | |
data-sap-ui-resourceroots='{"ReviewOrders": ""}'> | |
</script> |
btw: how do you make you code look like code?
Regards,
Michael
I also tryed:
<Label text="{/Positions}"/>
Positions.json: {"Positions": "hey"}
Not working. So the problem is not with the <List>, the problem is with the binding.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
try the items like this:
<:ObjectListItem title="{id}" />
I don't think you need the extra positions> path in the list item object
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.