Kliver Max
Kliver Max

Reputation: 5299

ExtJs extend component issue

I have a extend FormPanel:

Ext.ns('myapp');

myapp.StandartForm = Ext.extend(Ext.FormPanel, {
id: 'myForm'
,xtype: 'test'
,frame:true    

,initComponent: function(){
    var self = this;

        this.editWindow = new Ext.Window({
            id: 'editWSWin', 
            layout: 'fit',
            title:this.editPanelTitle,
            autoScroll:false,
            width:300,
            html:'hi'
        });


     var config = {                 
        items: [{
            layout:'column',
            items:[this.grid],
            buttons: [{
                text: 'Edit',
                id: "editBtn",                    
                handler: this.editFormCreate,
                scope: this,
                hidden: this.editbuttonHidden,
                disabled:true
            }] 
        }]};

        // apply config
        Ext.apply(this, config);
        Ext.apply(this.initialConfig, config);

        myapp.StandartForm.superclass.initComponent.call(this);      

}

, editFormCreate : function (){
    this.editWindow.show();
}
});
Ext.reg(myapp.StandartForm.prototype.xtype, myapp.StandartForm);

In this panel i press button Edit and window showing. After i close window and press Edit button again but get error:

TypeError: b.dom is undefined

I think it's mean that my window undifined.
How can i extend FormPanel to be able use window correctly?

UPDATE

function to create window:

           function test(){
            var editWindow = new Ext.Window({
            id: 'editWSWin', 
            layout: 'fit',
            title:this.editPanelTitle,
            autoScroll:false,
            width:300,
            html:'hi'
        });
               return editWindow
             }

and call it:

, editFormCreate : function (){
    test.show();
}

But its undifined.

Upvotes: 0

Views: 154

Answers (2)

Evan Trimboli
Evan Trimboli

Reputation: 30092

When you close the window, it gets destroyed, so you can't show it again. You need to either:

  • Set the closeAction property on the window
  • Create the window inside editFormCreate each time

Upvotes: 2

Mike Thomsen
Mike Thomsen

Reputation: 37524

When you close a Ext.Window, you dispose of the DOM elements it creates so there is nothing to show anymore. You need to instantiate a new one before showing it in this case.

Upvotes: 1

Related Questions