I am trying to bind a Value inside of an Array with Objects to a sap.ui.commons.DropdownBox .
My JSON-structure looks like that:
{
"forms": [
{
"name": "First Object"
},
{
"name": "Second Object"
}
]
}
Now I try to bindItems to my DropdownBox like that:
var oItemTemplate = new sap.ui.core.ListItem();
oItemTemplate.bindProperty("text", "{/name}");
var oModel = new sap.ui.model.json.JSONModel();
oModel.setData(oData);
sap.ui.getCore().setModel(oModel);
var oDropDown = new sap.ui.commons.DropdownBox("dropDownBox");
oDropDown.bindItems("/forms", oItemTemplate);
Unfortunately the Items, i am adding/binding to the Dropdown, are empty.
How to properly bind Items in an Array of Objects to a DropdownBox?
JSBIN-Example
Got the answer after a very restfully night :)
This is the working code snippet:
var oItemTemplate = new sap.ui.core.ListItem();
oItemTemplate.bindProperty("text", "name");
var oModel = new sap.ui.model.json.JSONModel();
oModel.setData(oData);
sap.ui.getCore().setModel(oModel);
var oDropDown = new sap.ui.commons.DropdownBox("dropDownBox");
oDropDown.bindItems("/forms", oItemTemplate);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.