Alja Mrak Tadel
Alja Mrak Tadel

Reputation: 27

Get Model Binding Path From Tree Item on Select

I'm using sap.m.Tree with JSON model. On the tree item select, I would like to see the path in the model.

I have made an example with a tree and callback for itemPress event:

var oTree = new sap.m.Tree("tree", {
  itemPress: function(oEvent) {
    console.log("itemPress event =", oEvent);
    var items = oEvent.getParameter("listItem");
    console.log("parameters", items);
  }
});

I guess I should get path from the model from oEvent parameter but can't see anything helpful as I inspect it.

Upvotes: 1

Views: 1970

Answers (1)

Boghyon Hoffmann
Boghyon Hoffmann

Reputation: 18044

You can get the binding path from the bound context of the pressed item:

oEvent.getParameter("listItem").getBindingContext(/*modelName*/).getPath()

API References

Upvotes: 2

Related Questions