reducing nesting confusion- fieldset objs? column objs?
In the following code, I am just creating the formPanel object, which I later use in my window items. This code works, by the way. Note also, that I have opted for the indenting pattern that I have been using for 20 years, where the opening and closing brace are on the same column. Sorry if it is not what you are used to seeing.
var editFormPanel = new Ext.form.FormPanel(
{
title: 'Edit Transaction Details',
labelWidth: 80,
heigh:400,
bodyStyle:'padding:5px 5px 0',
border: false,
items:
[
{
layout: 'column',
items:
[
{
columnWidth: .5,
layout: 'form',
title: 'Left',
border:false,
header: false,
bodyStyle:'padding:5px 5px 0',
items:
[
{
xtype: 'fieldset',
title: 'Closing Details',
autoHeight: true,
items:
[
{
xtype:'textfield',
fieldLabel:"Borrower First Name",
name:"borrowerFName"
},
{
xtype:'textfield',
fieldLabel:"Borrower Last Name",
name:"borrowerLName"
}
]
}
]
},
{
columnWidth: .5,
layout: 'form',
title: 'Right',
border:false,
header: false,
bodyStyle:'padding:5px 5px 0',
items:
[
{
xtype: 'fieldset',
title: 'Package',
autoHeight: true,
items:
[
{
xtype:'textfield',
fieldLabel:"Tracking",
name:"trackingNum"
}
]
},
{
xtype: 'fieldset',
title: 'Misc',
autoHeight: true,
items:
[
{
xtype:'textarea',
fieldLabel:"Notes",
name:"comments"
}
]
}
]
}
]
}
]
});
So- here is my question. Is there a way I can create my fieldsets and columns individually as an object, so as to make it more readable? And if I do so, is there a performance penalty?
I see the docs for Class Ext.form.FieldSet but I don't think I can create one of these using new. Similarly, I found Class Ext.layout.ColumnLayout, but I don't see a way to create an object for a single column.
If I could, then I could do something like this (fictitious code):
var fieldSet1 = new Ext.form.Fieldset(
{
title: 'Fieldset 1',
items:
[
{
fields...
}
]
}
... etc for fieldSet2, 3, 4
var editFormCol1 = new Ext.layout.Column(
{
title: 'column1',
width: .5,
items:
[ fieldSet1, fieldSet2 ]
}
var editFormCol2 = new Ext.layout.Column(
{
title: 'column1',
width: .5,
items:
[ fieldSet3, fieldSet4 ]
}
var editFormPanel = new Ext.form.FormPanel(
{
title: 'Edit Transaction Details',
labelWidth: 80,
heigh:400,
bodyStyle:'padding:5px 5px 0',
border: false,
items: [ editFormCol1, editFormCol2 ]
}
Is there a reasonable way to do something like I describe?
Thanks for a fantastic toolkit!
Note that you can declare config as string vars and use them where appropriate, so you don't have to have things indented 10+ tab stops across.
var cols = {
layout: 'column',
items:
[
{
columnWidth: .5,
....
}
var editFormPanel = new Ext.form.FormPanel(
{
title: 'Edit Transaction Details',
labelWidth: 80,
heigh:400,
bodyStyle:'padding:5px 5px 0',
border: false,
items:
[cols]
....
Hmm. Can you show me what that syntax would look like? This might be a nice solution- kinda like a #define in C.
Thanks
#If you have any other info about this subject , Please add it free.# |