【问题标题】:How to call a superclass method of Ext JS 3.4 Window如何调用 Ext JS 3.4 Window 的超类方法
【发布时间】:2013-04-07 21:28:51
【问题描述】:

我有一个像这样的窗口类:

    myWindow = Ext.extend(WindowAddItemUi, {

    initComponent: function() {

        WindowAddComponentPublic.superclass.initComponent.call(this);

    },

    close : function() {
        this.superclass().close(); //not working
        myWindow.superclass().close(); //also not working

    }

   });

我正在尝试覆盖一个窗口的close方法,并调用该窗口的超方法close,但是好像不起作用。
有谁知道如何正确调用它?

【问题讨论】:

    标签: extjs superclass


    【解决方案1】:
    close: function() {
        this.callParent();
    }
    

    【讨论】:

    • 在 initComponent 中你可以使用 this.callParent(arguments);
    • @JohanHaest 是的,但是如果你多次扩展组件并在父级initComponent中等待参数,它们需要通过。这个设计让你别想了。
    • this.callParent(); 对我不起作用。我得到一个错误this.callParent is not a function 现在我已经用一个事件监听器修复了它,但我希望没有它,只是覆盖窗口的关闭方法。我的解决方案:this.on('close', function() { this.dataviewComponents1.getStore().removeAll(); this.dataviewComponents2.getStore().removeAll(); }, this);
    【解决方案2】:

    是的,我终于成功了。 这是我的解决方案。

    close : function() {
     this.superclass().close.call(this); //this works
     // myWindow.superclass.close.call(this); //this also works 
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-04-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多