简体   繁体   English

openui5 getBinding()返回未定义

[英]openui5 getBinding() returning undefined

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 我了解绑定发生在onBeforeRendering中,因此我添加了一个onAfterRendering函数,该函数成功调用

However this.getBinding("_myAggregation") is still undefined, so that I cannot attach any event handler. 但是, this.getBinding(“ _ myAggregation”)仍未定义,因此我无法附加任何事件处理程序。 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. 我正在使用openui5版本1.28.15,否则该应用程序将正常工作:正确呈现JSONModel中的信息,处理编辑等。

Hope this might help you. 希望这对您有帮助。

http://jsbin.com/qagani/edit?html,js,output http://jsbin.com/qagani/edit?html,js,输出

The binding is more related to Managed Object rather than control itself. 绑定与受管对象更相关,而不是控件本身。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM