PDA

View Full Version : Windows with forms in them



alos
24 Nov 2007, 1:49 PM
Hello, I looked at some of the code and tutorials. I'm just starting and i have a simple problem...i cant make dialogs that contain a FormPanel :(

My code:



var forma= new Ext.FormPanel({
el: 'x-window-content',
labelWidth: 100, // label settings here cascade unless overridden
frame: true,
title: 'Formato de registro de Instituciónes',
bodyStyle: 'padding:20px 20px 0',
autoWidth: true,
height: '300px',
defaults: {
width: 'auto'
},
defaultType: 'textfield',
items: [
{
id: 'nombreInstitucion',
fieldLabel: 'Nombre',
name: 'nombreInstitucion',
allowBlank: false
},
{
id: 'telefono',
fieldLabel: 'Telefono',
name: 'telefonoInstitucion',
allowBlank: false
}

]//de los items
});
var window = new Ext.Window({
title: '',
id:'myWindow',
width: 400,
height:300,
minWidth: 300,
minHeight: 100,
layout: 'fit',
plain:true,
bodyStyle:'padding:5px;',
buttonAlign:'center',
items: forma
});
window.show(this);

I get a dialog with just one text field, no matter what I add to the form I can only see one component. Any ideas? Do I have to create "divs" for the window and its components?

Thanks =)

efege
24 Nov 2007, 1:56 PM
I tested your code, and found that it works provided that:

1. Remove the config el: 'x-window-content'. 'el' is not a config property.

2. Do not use window as a variable name, since there's already a global object with that name. (Firefox complains about this, and stops execution.) Call it win or any other name ;)

hendricd
24 Nov 2007, 2:01 PM
This is going to be a problem later (if not now). Since your creating a new Window each time, you cannot be assured that ''x-window-content'' element will exist after the first window is destroyed. The Panel will create the necessary container for you, so I wouldn't even specify an el.




var forma= new Ext.FormPanel({
el: 'x-window-content',
id: 'popupForm' ,
labelWidth: 100, // label settings here cascade unless overridden
frame: true,

hendricd
24 Nov 2007, 2:02 PM
Wow, Fernando types faster ;)

alos
25 Nov 2007, 1:08 PM
Hey, thanks guys! It works =)