I am working on the select box binding. I want to bind data to the select box which is coming from odata service. Below is my code. My model is set and I can get the model value in the console. But not able to bind to select box.
var oModel = this.getView().getModel("rulelist");
var Zid = '0';
var Zidentifier1 = 'Default Vendor';
var Zidentifier2 = '111111';
var aFilter = [];
var noModel = new sap.ui.model.json.JSONModel();
aFilter.push(new Filter("Zid", FilterOperator.EQ, Zid));
aFilter.push(new Filter("Zidentifier1", FilterOperator.EQ, Zidentifier1));
aFilter.push(new Filter("Zidentifier2", FilterOperator.EQ, Zidentifier2));
oModel.read("/ZruleAttributeSet", {
filters: aFilter,
success: function(data) {
var attrResult = data.results;
var headerFields = "";
var aTtributes = [];
for (var k = 0; k < attrResult.length; k++) {
aTtributes.push({attribute:attrResult[k].Zattribute});
headerFields += "attribute: "+attrResult[k].Zattribute + ",";
}
noModel.setData({
items: aTtributes
});
sap.ui.getCore().setModel(noModel, "newData");
console.log(sap.ui.getCore().getModel("newData"));
noModel.refresh(true);
},
error: function(e) {
MessageToast.show("No Data Found !!");
}
If this is an oData service you should use the oData model - probably sap.ui.model.odata.v2.ODataModel
.
Maybe the Data Binding and oData V4 tutorials might help you out?
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.