简体   繁体   English

属性元数据绑定断言失败

[英]Property Metadata Binding Assertion Failed

I have a View in my SAPUI5 application where I am creating a OData Model.我在我的 SAPUI5 应用程序中有一个视图,我正在其中创建一个 OData Model。

In the next step I want to use his metadata to bind a Property.在下一步中,我想使用他的元数据来绑定一个属性。

My error message is abap.js:64 Assertion failed: COLUMN/@sap:label is not a valid property path我的错误信息是 abap.js:64 Assertion failed: COLUMN/@sap:label is not a valid property path

I think here is another mistake because before i tried this, I had always a OData Model which i defined in the manifest file and it worked fine - but now when creating a Model in the same view it doesn't work.我认为这是另一个错误,因为在我尝试这个之前,我总是有一个 OData Model 我在清单文件中定义它并且工作正常 - 但现在在同一个视图中创建一个 Model 它不起作用。

I also thougt about to set the Model to the View, but I think its not neccessery because in the Path I am saying, please look at "oModel" OData Model for your data.我还想将 Model 设置为视图,但我认为这不是必需的,因为在我所说的路径中,请查看“oModel”OData Model 以获取您的数据。 {oModel</.... {o模型</....

Did I forgot something?我忘了什么吗?

        // creating model
        var oModel = new sap.ui.model.odata.v2.ODataModel("/sap/opu/odata/sap/xxxx/", "oModel");
                                

                    var oLabel = new sap.ui.comp.smartfield.SmartLabel({                            
                        text: "{oModel>/#showcase/" + column + "/@sap:label}" // {ODataModel>/#showcase/" + column + "/@sap:label}" // 
                    });

the "oModel" inside the line行内的“oModel”

text: "{oModel>/#showcase/" + column + "/@sap:label}"

refers to a name, under which you can assign the model to any Control that is inherited from sap.ui.base.ManagedObject .指的是一个名称,您可以在该名称下将 model 分配给从sap.ui.base.ManagedObject继承的任何控件。 it has no relationship to the variable name "oModel" that you use to create the model in JS.它与您在 JS 中用于创建 model 的变量名“oModel”没有任何关系。

the following should work (note, I replaced one occurrence of oModel with bla , the other with blubber to point out the difference以下应该有效(注意,我用bla替换了一次oModel ,另一个用blubber来指出区别

var bla = new sap.ui.model.odata.v2.ODataModel("/sap/opu/odata/sap/xxxx/");
                          
var oLabel = new sap.ui.comp.smartfield.SmartLabel({                            
    text: "{blubber>/#showcase/" + column + "/@sap:label}" 
});

oLabel.setModel(bla, "blubber")

or, alternatively:或者,或者:

var oLabel = new sap.ui.comp.smartfield.SmartLabel({
    models: {
        "blubber": new sap.ui.model.odata.v2.ODataModel("/sap/opu/odata/sap/xxxx/")
    },                            
    text: "{blubber>/#showcase/" + column + "/@sap:label}" 
});

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

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