on 05-21-2015 7:58 PM
Hi,
I have a json file in my project and would like to bind the data to some controls.
In the onInit function I am using the following code:
onInit : function (evt) {
// set mock model
var sPath = jQuery.sap.getModulePath("view.Over", "./../tile_data.json");
var oModel = new sap.ui.model.json.JSONModel(sPath);
this.getView().setModel(oModel);
},
My View.xml (from SAPUI5 Explored)
<mvc:View
height="100%"
controllerName="view.CampOver"
xmlns:mvc="sap.ui.core.mvc"
xmlns="sap.m">
<Page
showHeader="false"
enableScrolling="false" >
<TileContainer
id="container"
tileDelete="handleTileDelete"
tiles="{/TileCollection}">
<StandardTile
icon="sap-icon://{icon}"
type="{type}"
number="{number}"
numberUnit="{numberUnit}"
title="{title}"
info="{info}"
infoState="{infoState}" />
</TileContainer>
<footer>
<Toolbar>
<ToolbarSpacer/>
<Button text="Edit" press="handleEditPress" />
<Button text="Busy state" press="handleBusyPress" />
<ToolbarSpacer/>
</Toolbar>
</footer>
</Page>
</mvc:View>
But when I run the app no tiles occur. I am wondering how to check if the binding is working correct and how to debug the model in order to check if it is filled correct with data?
Thank you,
Vanessa
Hi Vanessa,
You are missing oModel.loadData("json file path",null,false);
Hope this helps.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Vanessa,
I would do two things:
first in the chrome debugger in the console look type in oModel.getJSON() to see the data.
secondly check the path of the JSON data file and load it specifically using sap.ui.localResources("JSON Model folder name") right before i create the instance of JSON MODEL.
Hope this helps
Hi Kedar,
thanks again for your answer. the console displays just an empty array.
I changed my code to:
var oModel = new sap.ui.model.json.JSONModel(); | |
oModel.loadData("https://webidetestinglqrb3m-s000XXXXXtrial.dispatcher.hanatrial.ondemand.com/tile_data.json"); | |
this.getView().setModel(oModel); |
I changed the url. I can call the url within the browser. But still no result.
Regards, Vanessa
Thanks for clearifying this. I wondering about one additional thing. The debugger is staying in the this.getView... line. When I enter this.getView.name in the console the browsers response is "". Could it be that the views name is not set correct and that the binding is not working because of this fact?
User | Count |
---|---|
87 | |
10 | |
10 | |
9 | |
7 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.