2016-08-05 124 views
0

我试图编辑名为PartKeepr(v0.1.9)的开源程序。在程序的特定部分,我想添加一个按钮,打开一个新的Ext.window.Window。我的代码如下,这是行不通的(我在extjs中很新,但我想我很困难,所以我接受所有关于从哪里开始学习的建议,我只是想学习从现有的代码,并通过寻找可用的代码的类似部件)Extjs通过单击按钮打开新的Ext.window.Window

Ext.define('PartKeepr.FindWindow',{ 
    extend:'Ext.window.Window', 
    constrainHeader: true, 
    title: i18n("Find Number"), 
    initComponent: function() { 
    this.okButton=Ext.create("Ext.button.Button",{ 
    text:i18n("OK")}); 
    this.buttons=[this.okButton]; 
    } 
}); 
涂抹一些东西
{ 
    xtype: 'button', 
    text: i18n("Find"), 
    name: 'findButton', 
    handler: Ext.bind(this.findNumber, this) 
} 
findNumber: function(){ 
    var j = new PartKeepr.FindWindow(); 
    j.show(); 
} 

编辑:当我按下查找按钮,控制台给我下面的错误信息:ext-all.js: 21 Uncaught TypeError:无法读取未定义的属性'插入'

回答

0

您需要调用超类initComponent方法:

Ext.define('PartKeepr.FindWindow', { 
    extend: 'Ext.window.Window', 
    constrainHeader: true, 
    title: i18n("Find Number"), 
    initComponent: function() { 
     this.okButton = Ext.create("Ext.button.Button", { 
      text: i18n("OK") 
     }); 
     this.buttons = [this.okButton]; 
     this.callParent(); 
    } 
});