2016-08-05 125 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(); 
    } 
});