1

我有一个扩展 Window 类 (qx.ui.window.Window) 的父小部件,并且这个窗口现在有几个孩子(我通过覆盖childControlImpl创建了孩子)。

现在我想从其中一个子类访问我在父类中的方法。我不想创建一个对象来调用这些方法,而是我想使用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
    }
    });
4

1 回答 1

0

尽管在 Nabble 上有交叉帖子,但这里是答案的要点:

_createChildControlImpl中,使用this._add而不是 this.add。

于 2013-10-07T09:09:28.273 回答