0

I'm using an OData Model from my SAP Gateway:

var oModel = new sap.ui.model.odata.ODataModel(url);
this.setModel(oModel, "model");

Now I have the requirement to display a property from the first line of an EntitySet.

I tried it with the following code in my XML view but without success:

<Text text="{model>/ZLLEDATSet/0/Date}" />

I thought the syntax should be "modelname>/entitySet/index/PropertyName".

Based on the answer from @SiddP: I tried the following but I get the error

Uncaught [object Object]

<Text text="{ 
  path: 'model>/ZLLEDATSet',
  formatter: function(value) {
    return value[0].Date;
  }
}"/>
Boghyon Hoffmann
  • 17,103
  • 12
  • 72
  • 170
alexander-fire
  • 1,082
  • 4
  • 27
  • 52
  • Does this answer your question? [bindProperty to Single OData Entity](https://stackoverflow.com/questions/23956091/bindproperty-to-single-odata-entity) – Boghyon Hoffmann Jan 15 '21 at 18:04

1 Answers1

0

Try this instead.

       text:{ 
            path: '/ZLLEDATSet', 
            formatter: function(value){
                           return value[0].Date;
                      }
            }

The above code in your question just works fine. See the jsbin :http://jsbin.com/kobocidose/edit?html,js,output

If you still get error just place alert(JSON.stringify(oModel.getData())); to check if the data is properly set to the model.There is a good chance the your data would show null.

SiddP
  • 1,603
  • 2
  • 14
  • 36