简体   繁体   English

SAPUI5-动态数据绑定到选择框

[英]SAPUI5 - Dynamic odata binding to select box

I am working on the select box binding. 我正在选择框绑定。 I want to bind data to the select box which is coming from odata service. 我想将数据绑定到来自odata服务的选择框。 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 . 如果这是oData服务,则应使用oData模型-可能是sap.ui.model.odata.v2.ODataModel

Maybe the Data Binding and oData V4 tutorials might help you out? 也许数据绑定和oData V4 教程可能对您有所帮助?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM