PDA

View Full Version : How to remove and readd a FormPanel into a Window



arfeen
15 Aug 2011, 4:05 AM
I'm having a problem where I would like to remove a FormPanel from a Window.


Here is my Form which is being loaded in a Window:



myForm = new Ext.FormPanel({
frame: true,
width: '100%',
id: 'myform',
layout: 'form',
autoHeight: true,
autoDestroy: false,
region: 'center',
monitorValid: true,
items: [{
xtype: 'textfield',
id: 'mytextfield',
fieldLabel: 'My Label',

}]
});

MyWindow = new Ext.Window({
title: 'MyWindow',
layout: 'auto',
resizable: false,
width: 717,
autoheight:true,
id:'mywindow',
closeAction:'hide',
closable: true,
items:[Ext.getCmp("myform")]


});


Now I want to remove this form and have to show another form, and I'm doing like this somewhere else:



MyWindow.removeAll();
MyWindow.add(Ext.getCmp("myAnotherForm"));


But this gives me error `"Uncaught TypeError: Cannot read property 'events' of undefined"` in ext-all-debug.js.


Is there anything, I'm missing here ?


Thanks.

arfeen
17 Aug 2011, 12:53 AM
I have worked around this problem by using the "destroy()" mehtod of the form and then add the same form in the window.