1

Anyone knows if is possible, and, how to binding a Control like "ObjectHeader" where the property "Title" is binding from one Entity and the agregations of this control like the ObjectStatus are binding from another Entity.

Here is the code:

bindObjectHeader: function() {

  var objectHeader = this.getView().byId("objectHeader");
  objectHeader.bindElement({
    path: "/Products" 
  });

  objectHeader.bindProperty("title", "Products/ToCategory/Description");
},

Well, the Entity Products has a CategoryId Property, and ToCategory is an association between the Entity Products and the Entity Categories... I want the correspondig Description of the given Category and Product

Thank you!

Boghyon Hoffmann
  • 17,103
  • 12
  • 72
  • 170
solrac
  • 629
  • 3
  • 16
  • 1
    Is this an OData context? Did you `$expand` the category of your product? – Marc Feb 05 '16 at 07:36
  • Does this answer your question? [How to make use of navigation property?](https://stackoverflow.com/questions/52483541/how-to-make-use-of-navigation-property) – Boghyon Hoffmann Jul 13 '21 at 17:13

1 Answers1

1

If you have an entity set which contains multiple entities as described in the JSON object below:

var oJson={"rootNode":{
            "node1":[
                     {"name":"myName"}
                    ],
            "node2":[
                     {"age":"15"}
                    ],
            "node3":[
                    {"subnode":"value1"},
                    {"subnode":"value2"},
                    ]
    }};

You can create a JSON model and set this data into the model and then set the JSON model at the core as mentioned below:

var oModel=new sap.ui.model.json.JSONModel();
    oModel.setData(oJson);
    sap.ui.getCore().setModel(oModel,"myModel");

You can now bind the title using one entity and aggregation(statuses) using another entity as described below:

var objectHeader=sap.ui.getCore().byId("objectheader");
      var objectStatus=new sap.m.ObjectStatus("objectstatus",{
          title:"{myModel>subnode}"
      });
      objectHeader.bindProperty("title", "myModel>/rootNode/node1/0/name");
      objectHeader.bindAggregation("statuses","myModel>/rootNode/node3",objectStatus);

Hope this answer helps you.

abhhab
  • 253
  • 2
  • 6
  • 22