Element Binding in Element Binding in SAPUI5

1.1k Views Asked by At

I'm using element binding in XML to get data from an OData service in the controller:

{myModel2>/oData/ProdOrdSet('123456789')/Gmein}

The whole thing should now work with dynamic numbers instead of 123456789. I started with the following approach:

{myModel2>/oData/ProdOrdSet('{myModelLD>/Aufnr}')/Gmein}

So another JSON Model and another element in the first. Unfortunately this did not work, kindly help?

1

There are 1 best solutions below

0
On BEST ANSWER

Try to get the ID in a local variable and form the binding path to bind. Instead of this

{myModel2>/oData/ProdOrdSet('{myModelLD>/Aufnr}')/Gmein}

try binding as below:

var id = getModel("myModelLD").getProperty("/Aufnr");
var sPath = "myModel2>/oData/ProdOrdSet('"+id+"')/Gmein";
this.getView().bindElement(sPath);