简体   繁体   中英

Extjs opening new Ext.window.Window by clicking a button

I'm trying to edit open source program called PartKeepr (v0.1.9). In a specific part of program I want to add a button that opens a new Ext.window.Window. My codes are as following which doesn't work (I'm pretty new in extjs but I'm given a hard task I guess, so I'm open to all advice for where to start learning, I'm just trying to learn from existing codes and apply some things by looking similar parts of available code)

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();
}

Edit: When I press the find button, console giving me the following error: ext-all.js:21 Uncaught TypeError: Cannot read property 'insert' of undefined

You need to call the superclass initComponent method:

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();
    }
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM