mystix
9 Apr 2008, 7:22 PM
Needed a spacer xtype for use in FormPanels, so i whipped up a simple now-simplified one:
Ext.ns('Ext.ux.form'); // set up Ext.ux.form namespace
/**
* @class Ext.ux.form.Spacer
* @extends Ext.BoxComponent
* Utility spacer class.
* @constructor
* @param {Number} height (optional) Spacer height in pixels (defaults to 22).
*/
Ext.ux.form.Spacer = Ext.extend(Ext.BoxComponent, {
height: 22,
autoEl: 'div' // thanks @jack =)
});
Ext.reg('spacer', Ext.ux.form.Spacer);
Example usage (adapted from examples/form/dynamic.html. additions in red):
var simple = new Ext.FormPanel({
labelWidth: 75, // label settings here cascade unless overridden
url:'save-form.php',
frame:true,
title: 'Simple Form',
bodyStyle:'padding:5px 5px 0',
width: 350,
defaults: {width: 230},
defaultType: 'textfield',
items: [{
fieldLabel: 'First Name',
name: 'first',
allowBlank:false
},{
fieldLabel: 'Last Name',
name: 'last'
},{
xtype: 'spacer'
},{
fieldLabel: 'Company',
name: 'company'
}, {
fieldLabel: 'Email',
name: 'email',
vtype:'email'
}, new Ext.form.TimeField({
fieldLabel: 'Time',
name: 'time',
minValue: '8:00am',
maxValue: '6:00pm'
})
],
buttons: [{
text: 'Save'
},{
text: 'Cancel'
}]
});
simple.render(document.body);
Screenshot:
http://img143.imageshack.us/img143/7531/extuxformspacerzu6.png
enjoy ;)
[edit 1]
p.s. i hope noone else has done this before... :-?
aww shucks, someone did beat me to it... http://extjs.com/forum/showthread.php?t=26541
BUT mine's more elegant (???) :> :))
[edit 2]
as expected, i'll be eating my own words. :)
to anyone who cares to use this, plugin code's been updated
Ext.ns('Ext.ux.form'); // set up Ext.ux.form namespace
/**
* @class Ext.ux.form.Spacer
* @extends Ext.BoxComponent
* Utility spacer class.
* @constructor
* @param {Number} height (optional) Spacer height in pixels (defaults to 22).
*/
Ext.ux.form.Spacer = Ext.extend(Ext.BoxComponent, {
height: 22,
autoEl: 'div' // thanks @jack =)
});
Ext.reg('spacer', Ext.ux.form.Spacer);
Example usage (adapted from examples/form/dynamic.html. additions in red):
var simple = new Ext.FormPanel({
labelWidth: 75, // label settings here cascade unless overridden
url:'save-form.php',
frame:true,
title: 'Simple Form',
bodyStyle:'padding:5px 5px 0',
width: 350,
defaults: {width: 230},
defaultType: 'textfield',
items: [{
fieldLabel: 'First Name',
name: 'first',
allowBlank:false
},{
fieldLabel: 'Last Name',
name: 'last'
},{
xtype: 'spacer'
},{
fieldLabel: 'Company',
name: 'company'
}, {
fieldLabel: 'Email',
name: 'email',
vtype:'email'
}, new Ext.form.TimeField({
fieldLabel: 'Time',
name: 'time',
minValue: '8:00am',
maxValue: '6:00pm'
})
],
buttons: [{
text: 'Save'
},{
text: 'Cancel'
}]
});
simple.render(document.body);
Screenshot:
http://img143.imageshack.us/img143/7531/extuxformspacerzu6.png
enjoy ;)
[edit 1]
p.s. i hope noone else has done this before... :-?
aww shucks, someone did beat me to it... http://extjs.com/forum/showthread.php?t=26541
BUT mine's more elegant (???) :> :))
[edit 2]
as expected, i'll be eating my own words. :)
to anyone who cares to use this, plugin code's been updated