javascriptxmlsapui5element-binding

Element Binding in Element Binding in SAPUI5


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?


Solution

  • 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);