2013-09-24 28 views
1

我有(通過覆蓋childControlImpl我創建了子女)擴展窗口類(qx.ui.window.Window)和這個窗口現在已經幾個孩子的家長控件。如何訪問用戶控件父定義的方法

現在我想從其中一個子類訪問父類中的方法。我不想創建一個對象來調用方法,而是我想用getLayoutParent方法來做到這一點。

但是,當我可以叫getLayoutParent從子類的方法,我可以訪問是內置的方法,但我不能訪問我所創建的任何方法。

我該怎麼做到這一點?

代碼示例:

qx.Class.define("project.WrkAttrWindow",{ 

extend : qx.ui.window.Window, 

construct: function() { 
    this.base(arguments); 
    this.__table = this._createChildControl("table"); 
}, 
members: { 

__table:null 

_createChildControlImpl : function(id) 
{ 
    var control; 
    switch(id) 
    { 
    case "table": 
     control = new project.WrkAttrTable(); 
     this.add(control); 
     break; 
    } 
return control || this.base(arguments, id); 
}, 

getPrjId:function() { 
console.log(I want to call this function); 
} 
}); 

子構件

qx.Class.define("project.WrkAttrTable",{ 

extend: qx.ui.table.Table, 

statics: { 
    colKeys:["id","name","description"] 
}, 

construct: function() { 

    this.base(arguments); 
      //some code here 
    }, 

    members: 
    { 
     //call parent method from here 
     this.getLayoutParent().getPrjId(); // does not work 
    } 
    }); 
+1

的問題也問及nabble.com看到:http://qooxdoo.678.n2.nabble.com/How-to-access-user-defined-methods-of-widget-parent-tp7584648.html –

回答

0

儘管在Nabble交叉後,這裏是從answer要點:

在_ createChildControlImpl ,請使用this._add而不是this.add。

+0

由於我在這裏無法得到答案,所以我在Nabble上發佈了相同的答案。而且由於基督徒已經就這個問題對這個問題進行了評論,所以我沒有打算補充答案。但謝謝你這樣做。 – bharathp

相關問題