PDA

View Full Version : [solved] many forms



Radziu
12 Feb 2008, 6:07 AM
i have a project when i useing a lot of forms with many fields what will be repeating eg.

form1 (textField1, textField2....)
form2 (textField2, combo1...) etc.

when i try this tutorial
http://extjs.com/learn/Tutorial:Getting_Started_with_Forms
the field can be use only one time. is any resolution for this?

devnull
12 Feb 2008, 8:36 AM
create a layout config object stored in a var, then pass it to the form constructor each time a new form is created.

Radziu
13 Feb 2008, 5:13 AM
but i need this fields in different configurations. i haven't got forms which looks the same only some fields are repeating

devnull
13 Feb 2008, 9:36 AM
create the individual fields as config objects stored in arrays and include them in the form's layout config then. same concept, just applied more specifically.

Radziu
14 Feb 2008, 1:50 AM
i'm trying to do sth like:




var field1 = new Ext.form.NumberField({
fieldLabel: 'lab1',
name: 'name1',
id:'id1'
});
etc....


for example i have 15 different fields (field1, field2...etc) and i'm trying to input fields to the forms



var form1 = new Ext.FormPanel({
region:'center',
frame:true,
autoScroll:true,
bodyStyle:'padding:5px 5px 0',
width: 350,

items: [
field1,
field3,...

another FormPanel:


var form2 = new Ext.FormPanel({
region:'center',
frame:true,
autoScroll:true,
bodyStyle:'padding:5px 5px 0',
width: 350,

items: [
field3,
field8,...etc..

when i do sth like this fields are only in one formPanel

devnull
15 Feb 2008, 9:33 AM
var field1 = {
fieldLabel: 'lab1',
name: 'name1',
id:'id1'
};



var form1 = new Ext.FormPanel({
region:'center',
frame:true,
autoScroll:true,
bodyStyle:'padding:5px 5px 0',
width: 350,

items: [
new Ext.form.NumberField(field1),
new Ext.form.NumberField(field3),...

perhaps it could even be simplified more than that, i havent actually tried it.

Radziu
20 Feb 2008, 3:08 AM
ok it works but how to make a dynamic id? i mean that every eg. field1 should have to different id eg. id1, 1d2....etc.

blater
20 Feb 2008, 4:37 AM
Assign an id when you create the items in the form panel.
e.g.


function newNumberField(id, config) {
config.id = id;
return new Ext.form.NumberField(config);
}
...



var field1 = {
fieldLabel: 'lab1',
name: 'name1',
id:'id1'
};
var field3 = {
fieldLabel: 'lab3',
name: 'name3',
id:'id3'
};


var form1 = new Ext.FormPanel({
region:'center',
frame:true,
autoScroll:true,
bodyStyle:'padding:5px 5px 0',
width: 350,

items: [
newNumberField('anID',field1),
newNumberField('anotherID', field3)
]
});

Condor
20 Feb 2008, 4:40 AM
Or:


items: [
new Ext.form.NumberField(Ext.applyIf({id: 'id1'}, field1)),
new Ext.form.NumberField(Ext.applyIf({id: 'id2'}, field3)),
...

Radziu
20 Feb 2008, 4:46 AM
wow it works! Thanks!