1
votes

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!

1
Is this an OData context? Did you $expand the category of your product?Marc
Does this answer your question? How to make use of navigation property?Boghyon Hoffmann

1 Answers

1
votes

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.