Search code examples
odatasapui5

How to get item table values using OData Model?


I have a OData model and data is as follows

enter image description here

Here, Under ZRECRUITMENT_TRACERRzSet(1), I have "toCandidates" which is Association and it has item level data.

How can I access it's values in the controller.

I tried using

oModel.getProperty('/ZRECRUITMENT_TRACERRzSet(1)/toCandidates')

But it's not helping.


Solution

  • You need to set the 'expand' property in your binding, so whenever the request is sent to the OData service, the "toCandidates" node will come with the data in the response, and not the URL only. Then your getProperty(...) will give you the data.

    Whenever you are binding your data you need to do something like this (for example with ElementBinding):

     oMyControl.bindElement({ 
         path: "/ZRECRUITMENT_TRACERRzSet(1)",
         parameters: {expand: "toCandidates"} 
     });