3 * Copyright(c) 2006-2010 Ext JS, Inc.
5 * http://www.extjs.com/license
8 * @class Ext.form.FieldSet
10 * Standard container used for grouping items within a {@link Ext.form.FormPanel form}.
12 var form = new Ext.FormPanel({
13 title: 'Simple Form with FieldSets',
14 labelWidth: 75, // label settings here cascade unless overridden
17 bodyStyle:'padding:5px 5px 0',
19 renderTo: document.body,
20 layout:'column', // arrange items in columns
21 defaults: { // defaults applied to items
24 bodyStyle: 'padding:4px'
27 // Fieldset in Column 1
34 anchor: '-20' // leave room for error icon
36 defaultType: 'textfield',
46 // Fieldset in Column 2 - Panel inside
48 title: 'Show Panel', // title, header, or checkboxToggle creates fieldset header
52 collapsed: true, // fieldset initially collapsed
57 title: 'Panel inside a fieldset',
65 * @param {Object} config Configuration options
68 Ext.form.FieldSet = Ext.extend(Ext.Panel, {
70 * @cfg {Mixed} checkboxToggle <tt>true</tt> to render a checkbox into the fieldset frame just
71 * in front of the legend to expand/collapse the fieldset when the checkbox is toggled. (defaults
73 * <p>A {@link Ext.DomHelper DomHelper} element spec may also be specified to create the checkbox.
74 * If <tt>true</tt> is specified, the default DomHelper config object used to create the element
76 * {tag: 'input', type: 'checkbox', name: this.checkboxName || this.id+'-checkbox'}
80 * @cfg {String} checkboxName The name to assign to the fieldset's checkbox if <tt>{@link #checkboxToggle} = true</tt>
81 * (defaults to <tt>'[checkbox id]-checkbox'</tt>).
84 * @cfg {Boolean} collapsible
85 * <tt>true</tt> to make the fieldset collapsible and have the expand/collapse toggle button automatically
86 * rendered into the legend element, <tt>false</tt> to keep the fieldset statically sized with no collapse
87 * button (defaults to <tt>false</tt>). Another option is to configure <tt>{@link #checkboxToggle}</tt>.
90 * @cfg {Number} labelWidth The width of labels. This property cascades to child containers.
93 * @cfg {String} itemCls A css class to apply to the <tt>x-form-item</tt> of fields (see
94 * {@link Ext.layout.FormLayout}.{@link Ext.layout.FormLayout#fieldTpl fieldTpl} for details).
95 * This property cascades to child containers.
98 * @cfg {String} baseCls The base CSS class applied to the fieldset (defaults to <tt>'x-fieldset'</tt>).
100 baseCls : 'x-fieldset',
102 * @cfg {String} layout The {@link Ext.Container#layout} to use inside the fieldset (defaults to <tt>'form'</tt>).
106 * @cfg {Boolean} animCollapse
107 * <tt>true</tt> to animate the transition when the panel is collapsed, <tt>false</tt> to skip the
108 * animation (defaults to <tt>false</tt>).
110 animCollapse : false,
113 onRender : function(ct, position){
115 this.el = document.createElement('fieldset');
116 this.el.id = this.id;
117 if (this.title || this.header || this.checkboxToggle) {
118 this.el.appendChild(document.createElement('legend')).className = this.baseCls + '-header';
122 Ext.form.FieldSet.superclass.onRender.call(this, ct, position);
124 if(this.checkboxToggle){
125 var o = typeof this.checkboxToggle == 'object' ?
126 this.checkboxToggle :
127 {tag: 'input', type: 'checkbox', name: this.checkboxName || this.id+'-checkbox'};
128 this.checkbox = this.header.insertFirst(o);
129 this.checkbox.dom.checked = !this.collapsed;
130 this.mon(this.checkbox, 'click', this.onCheckClick, this);
135 onCollapse : function(doAnim, animArg){
137 this.checkbox.dom.checked = false;
139 Ext.form.FieldSet.superclass.onCollapse.call(this, doAnim, animArg);
144 onExpand : function(doAnim, animArg){
146 this.checkbox.dom.checked = true;
148 Ext.form.FieldSet.superclass.onExpand.call(this, doAnim, animArg);
152 * This function is called by the fieldset's checkbox when it is toggled (only applies when
153 * checkboxToggle = true). This method should never be called externally, but can be
154 * overridden to provide custom behavior when the checkbox is toggled if needed.
156 onCheckClick : function(){
157 this[this.checkbox.dom.checked ? 'expand' : 'collapse']();
161 * @cfg {String/Number} activeItem
165 * @cfg {Mixed} applyTo
169 * @cfg {Boolean} bodyBorder
173 * @cfg {Boolean} border
177 * @cfg {Boolean/Number} bufferResize
181 * @cfg {Boolean} collapseFirst
185 * @cfg {String} defaultType
189 * @cfg {String} disabledClass
193 * @cfg {String} elements
197 * @cfg {Boolean} floating
201 * @cfg {Boolean} footer
205 * @cfg {Boolean} frame
209 * @cfg {Boolean} header
213 * @cfg {Boolean} headerAsText
217 * @cfg {Boolean} hideCollapseTool
221 * @cfg {String} iconCls
225 * @cfg {Boolean/String} shadow
229 * @cfg {Number} shadowOffset
233 * @cfg {Boolean} shim
237 * @cfg {Object/Array} tbar
245 * @cfg {Ext.Template/Ext.XTemplate} toolTemplate
249 * @cfg {String} xtype
265 * @method getBottomToolbar
269 * @method getTopToolbar
273 * @method setIconClass
297 Ext.reg('fieldset', Ext.form.FieldSet);