on 01-30-2021 12:36 PM
Hi,
Object page layout.
Created a JSON model and imported it into controller.
onInit: function () {
var oModel = new JSONModel("../model/data.json");
this.getView().setModel(oModel, "portfolio");
}
Tried using it in the view, but the model is not loading it seems. Title is not showing.
<ObjectPageLayout id="ObjectPageLayout">
<headerTitle>
<ObjectPageDynamicHeaderTitle>
<expandedHeading>
<m:Title text="{portfolio>/name}" wrapping="true"/>
</expandedHeading>
<expandedContent>
<m:Text text="{portfolio>/designation}"/>
</expandedContent>
<snappedContent>
<m:Text text="{portfolio>/designation}"/>
</snappedContent>
-----------
Console:
Debugger:
Also i have one more doubt:
when to use the below in JSON Model binding:
1) >/ (portfolio>/name)
2) > (portfolio>name)
3) / (portfolio/name)
First of all, your backend returns status 503 (service unavailable) - you need to solve that. Check network tab in chrome dev tools, if it is using correct path, etc.
In debugger, oModel is defined as variable, but contains no data (JSON models store their data in oData member of the object, which is oData:{} in your screenshot.
For your second question,
1: {portfolio>/name}
2: {portfolio>name}
3: {portfolio/name}
1 is binding to "name" property inside the root of the model "portfolio"
2 is binding to "name" property in model "portfolio" relatively to binding context
so, if your portfolio model had following content:
{ name: "Sherman", father: { name: "Mr. Peabody" }}
then 1 would always point to "Sherman"
2 will depend on binding context of the control, in which you use the binding, e.g.
<Text text="{portfolio>name}" binding="{portfolio>/father}" />
will display "Mr. Peabody"
3 is binding to portfolio/name in default model relatively to binding context
PS: have a look at Binding documentation
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
var oModel =new JSONModel("../model/data.json");
change to
var sPath=sap.ui.require.toUrl("../model/data.json")
var oModel = new JSONModel(sPath);
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
101 | |
13 | |
13 | |
11 | |
11 | |
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.