Sunday, 1 November 2015

how to add data to the json data to the combo box in sapui5 ?


use this method in the init method of your  controller.


var mData = {
"combotype":"ComboText",
"rajendra" : [{
"Name" :"Jan",
"Value":"1"
},
{
"Name" :"Feb",
"Value":"2"
},
{
"Name" :"March",
"Value":"3"
}]
};

var oModel = new sap.ui.model.json.JSONModel();
oModel.setData(mData);
this.getView().setModel(oModel);




and your xml view should contain 


<ComboBox   class ="Combo_box1" items="{/rajendra}" >
<items>
<core:Item key="{Name}" text="{Value}" />
</items>
</ComboBox>

No comments:

Post a Comment