PDA

View Full Version : Reuse Form in Window



mauro_monti
20 May 2010, 6:13 AM
Hi People,

I'm having troubles trying to reuse a form in differents windows. Basically, i have a form panel instance and two buttons.

The action on each button obtain a new instance of Window, and add the form panel to the window.

The problem is when i click in the first button, get the window instance, close the window and do the click again in the button to get a new Window instance. The conent of the window is empty. I mean, it seems like the form panel cannot be add to the new window instance.

The code:


var wndA = null;
var wndB = null;
Ext.onReady(function(){
var form = new Ext.FormPanel({ layout: 'form', items: [{xtype: 'textfield', fieldLabel: 'labelA', name: 'tfA'}]});
//var formB = new Ext.FormPanel({ layout: 'form', items: [{xtype: 'textfield', fieldLabel: 'labelB', name: 'tfB'}]});

var close = function(params) {
params.close();
};

var win = function() {
var tempWnd = new Ext.Window({
layout: 'fit',
autoDestroy : true,
height: 300,
width: 300
});
var btnSalir = { xtype: 'button', text: 'Salir', handler: close.createDelegate(btnSalir, [tempWnd]) };
tempWnd.addButton(btnSalir);
return tempWnd;
};

// == Content Panel (Layout).
var panel = new Ext.Panel({
layout: 'table',
items: [{
xtype: 'button', text: 'Get Wnd A',
listeners: {
'click' : function(a, b) {
wndA = win();
wndA.removeAll(false);
wndA.add(form);
wndA.doLayout();
wndA.show();
}
}
},{
xtype: 'button', text: 'Get Wnd B',
listeners: {
'click' : function(a, b) {
wndB = win();
wndB.removeAll(false);
wndB.destroy();
wndB.add(form);
wndB.doLayout();
wndB.show();
}
}
}
]
});
panel.render('panelLocLlama');
});


Can anybody helpme?20597

mauro_monti
20 May 2010, 8:17 AM
Sorry, this post might be on the Help forum and not on the Extensions and Plugins. Can any administrator delete this post?.
I will post it again in the correct forum.

patrickculverton
23 May 2010, 11:42 PM
Sorry, this post might be on the Help forum and not on the Extensions and Plugins. Can any administrator delete this post?.
I will post it again in the correct forum.

We will contact the admin for this post. Don't worry about that.