on 07-27-2016 5:18 AM
Hello
I am trying to display json data in table but am getting blank table everytime. Here is my code:
<Table id="Table_Id"
items="{oModel/Hier}"
noDataText="No Data Created Yet" >
<columns>
<Column>
<Text text="ID" />
</Column>
<Column >
<Text text="Name" />
</Column>
</columns>
<items>
<ColumnListItem>
<cells>
<Text text="{oModel>ID}" />
<Text text="{oModel>NAME}" />
</cells>
</ColumnListItem>
</items>
</Table>
In controller
var oModel = new sap.ui.model.json.JSONModel({
Hier: [{
ID: "KLJNB",
NAME: "AJY",
},
{
ID: "OLJNB",
NAME: "OAJY",
}
]
});
sap.ui.getCore().setModel(oModel,"omodel");
console.log(oModel);
},
Hi Justin,
Also one more thing to add to Deepak's solution, your 'items' binding path should be:
items="{oModel>/Hier}"
Regards,
Sai.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Justin,
May be you have not added this in bootstrap:
data-sap-ui-xx-bindingSyntax="complex"
If you had corrected the code then it should work. I tried and it is working fine for me: JS Bin - Collaborative JavaScript Debugging
Regards,
Sai.
Hi Justin,
bind table with "{/Hier}" and for each column just give "{ID}" and "{NAME}"
When u bind table with "{/Hier}" each object from this array is automatically binded with each rows... so in rows just specify property name as {ID} .. try this out
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Check for difference in the name of model.
Change the name of model when setting it to oModel instead of omodel in controller.
i.e. sap.ui.getCore().setModel(oModel, "oModel").
Thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
96 | |
11 | |
11 | |
10 | |
9 | |
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.