chiranjeevibmse chiranjeevibmse - 4 months ago 42
JSON Question

binding issue with sap.m.List and model configured in manifest.json

i need to show the list with items are binding to the model which is configured in the manifest.json for component.

model which configured in manifest.json

"models": {
"i18n": {
"type": "sap.ui.model.resource.ResourceModel",
"settings": {
"bundleName": "com.xxxxx.yy.DemandFilter.i18n.i18n"
}
},
"priority": {
"type": "sap.ui.model.json.JSONModel",
"uri": "model/priority.json"
},
"status": {
"type": "sap.ui.model.json.JSONModel",
"uri": "model/status.json"
}
}


the priority and status json are just array of objects as below

{
"status":[
{
"name" : "Created",
"selected":false
},
{
"name" : "Processed",
"selected":false
},
{
"name" : "Released",
"selected":false
},
{
"name" : "Completed",
"selected":false
},
{
"name" : "Closed",
"selected":false
}]
}


i am placing the view through Component as below

new sap.ui.core.ComponentContainer({
height : "100%",
name : "com.xxxxx.yyy.DemandFilter"
})


My view is XML view and list is added as below

<List headerText="{i18n>status}" items="{ path:'status>/status' }"
selectionChange="onStatusSelection" mode="MultiSelect">
<items>
<InputListItem label="{name}" selected="{selected}">
</InputListItem>
</items>
</List>


The Number of list items are correct but the name and selected are not binding properly

enter image description here

if i set the model to the view in onInit of the Controller this is working fine.

Please suggest me where i have made the mistake?

Answer

Properties of control also need to be specified with model's alias.

<InputListItem label="{status>name}" selected="{status>selected}">