How can I retrieve the View
/Fragment
a sap.ui.core.Control
belongs to?
BR Chris
You can walk up the parents until you find the View. You should however not rely on identifiers. Use the Class or Metadata to identify a View:
buttonPress: function(oEvent){
var b = oEvent.getSource();
while (b && b.getParent) {
b = b.getParent();
if (b instanceof sap.ui.core.mvc.View){
console.log(b.getMetadata()); //you have found the view
break;
}
}
}
Example on JSBin.
Fragments are not added to the control tree. So you cannot find them. You can however find the view they have been added to.