0
votes

I have a View in my SAPUI5 application where I am creating a 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

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.

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. {oModel</....

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}" // 
                    });
1

1 Answers

0
votes

the "oModel" inside the line

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. it has no relationship to the variable name "oModel" that you use to create the model in JS.

the following should work (note, I replaced one occurrence of oModel with bla, the other with blubber to point out the difference

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}" 
});