I am trying to listen to an event that indicates a custom control's aggregation binding has changed.
My goal is to locate the binding object associated with the aggregation and attach a handler to it.
I understand that binding occurs within onBeforeRendering, so I added an onAfterRendering function which is called successfully
However this.getBinding("_myAggregation") is still undefined, so that I cannot attach any event handler. The outline of the code is as follows:
sap.ui.core.Control.extend("myControl",
{
metadata : {
properties : {
...
},
aggregations : {
_myAggregation : {
type : "myInnerControl",
multiple : false
}
},
events : {
...
}
},
init : function() {
var self = this;
self.setAggregation("_myAggregation", new myInnerControl.bindElement("queryModel>"));
},
onAfterRendering : function(oEvent) {
if (sap.ui.core.Control.prototype.onAfterRendering) {
sap.ui.core.Control.prototype.onAfterRendering.apply(this, arguments);
}
this.getBinding("_myAggregation").attachChange(function() {
alert("model change");
});
},
renderer : function(oRm, oControl) {
...
}
});
I am using openui5 version 1.28.15 The application works otherwise: correctly renders the information in the JSONModel, handles edits etc.