3 <title>The source code</title>
4 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
5 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
7 <body onload="prettyPrint();">
8 <pre class="prettyprint lang-js">/*!
10 * Copyright(c) 2006-2009 Ext JS, LLC
12 * http://www.extjs.com/license
14 <div id="cls-Ext.form.FieldSet"></div>/**
\r
15 * @class Ext.form.FieldSet
\r
16 * @extends Ext.Panel
\r
17 * Standard container used for grouping items within a {@link Ext.form.FormPanel form}.
\r
19 var form = new Ext.FormPanel({
\r
20 title: 'Simple Form with FieldSets',
\r
21 labelWidth: 75, // label settings here cascade unless overridden
\r
22 url: 'save-form.php',
\r
24 bodyStyle:'padding:5px 5px 0',
\r
26 renderTo: document.body,
\r
27 layout:'column', // arrange items in columns
\r
28 defaults: { // defaults applied to items
\r
31 bodyStyle: 'padding:4px'
\r
34 // Fieldset in Column 1
\r
37 title: 'Fieldset 1',
\r
41 anchor: '-20' // leave room for error icon
\r
43 defaultType: 'textfield',
\r
45 fieldLabel: 'Field 1'
\r
47 fieldLabel: 'Field 2'
\r
49 fieldLabel: 'Field 3'
\r
53 // Fieldset in Column 2 - Panel inside
\r
55 title: 'Show Panel', // title, header, or checkboxToggle creates fieldset header
\r
58 checkboxToggle: true,
\r
59 collapsed: true, // fieldset initially collapsed
\r
64 title: 'Panel inside a fieldset',
\r
72 * @param {Object} config Configuration options
\r
75 Ext.form.FieldSet = Ext.extend(Ext.Panel, {
\r
76 <div id="cfg-Ext.form.FieldSet-checkboxToggle"></div>/**
\r
77 * @cfg {Mixed} checkboxToggle <tt>true</tt> to render a checkbox into the fieldset frame just
\r
78 * in front of the legend to expand/collapse the fieldset when the checkbox is toggled. (defaults
\r
79 * to <tt>false</tt>).
\r
80 * <p>A {@link Ext.DomHelper DomHelper} element spec may also be specified to create the checkbox.
\r
81 * If <tt>true</tt> is specified, the default DomHelper config object used to create the element
\r
82 * is:</p><pre><code>
\r
83 * {tag: 'input', type: 'checkbox', name: this.checkboxName || this.id+'-checkbox'}
\r
86 <div id="cfg-Ext.form.FieldSet-checkboxName"></div>/**
\r
87 * @cfg {String} checkboxName The name to assign to the fieldset's checkbox if <tt>{@link #checkboxToggle} = true</tt>
\r
88 * (defaults to <tt>'[checkbox id]-checkbox'</tt>).
\r
90 <div id="cfg-Ext.form.FieldSet-collapsible"></div>/**
\r
91 * @cfg {Boolean} collapsible
\r
92 * <tt>true</tt> to make the fieldset collapsible and have the expand/collapse toggle button automatically
\r
93 * rendered into the legend element, <tt>false</tt> to keep the fieldset statically sized with no collapse
\r
94 * button (defaults to <tt>false</tt>). Another option is to configure <tt>{@link #checkboxToggle}</tt>.
\r
96 <div id="cfg-Ext.form.FieldSet-labelWidth"></div>/**
\r
97 * @cfg {Number} labelWidth The width of labels. This property cascades to child containers.
\r
99 <div id="cfg-Ext.form.FieldSet-itemCls"></div>/**
\r
100 * @cfg {String} itemCls A css class to apply to the <tt>x-form-item</tt> of fields (see
\r
101 * {@link Ext.layout.FormLayout}.{@link Ext.layout.FormLayout#fieldTpl fieldTpl} for details).
\r
102 * This property cascades to child containers.
\r
104 <div id="cfg-Ext.form.FieldSet-baseCls"></div>/**
\r
105 * @cfg {String} baseCls The base CSS class applied to the fieldset (defaults to <tt>'x-fieldset'</tt>).
\r
107 baseCls : 'x-fieldset',
\r
108 <div id="cfg-Ext.form.FieldSet-layout"></div>/**
\r
109 * @cfg {String} layout The {@link Ext.Container#layout} to use inside the fieldset (defaults to <tt>'form'</tt>).
\r
112 <div id="cfg-Ext.form.FieldSet-animCollapse"></div>/**
\r
113 * @cfg {Boolean} animCollapse
\r
114 * <tt>true</tt> to animate the transition when the panel is collapsed, <tt>false</tt> to skip the
\r
115 * animation (defaults to <tt>false</tt>).
\r
117 animCollapse : false,
\r
120 onRender : function(ct, position){
\r
122 this.el = document.createElement('fieldset');
\r
123 this.el.id = this.id;
\r
124 if (this.title || this.header || this.checkboxToggle) {
\r
125 this.el.appendChild(document.createElement('legend')).className = 'x-fieldset-header';
\r
129 Ext.form.FieldSet.superclass.onRender.call(this, ct, position);
\r
131 if(this.checkboxToggle){
\r
132 var o = typeof this.checkboxToggle == 'object' ?
\r
133 this.checkboxToggle :
\r
134 {tag: 'input', type: 'checkbox', name: this.checkboxName || this.id+'-checkbox'};
\r
135 this.checkbox = this.header.insertFirst(o);
\r
136 this.checkbox.dom.checked = !this.collapsed;
\r
137 this.mon(this.checkbox, 'click', this.onCheckClick, this);
\r
142 onCollapse : function(doAnim, animArg){
\r
144 this.checkbox.dom.checked = false;
\r
146 Ext.form.FieldSet.superclass.onCollapse.call(this, doAnim, animArg);
\r
151 onExpand : function(doAnim, animArg){
\r
153 this.checkbox.dom.checked = true;
\r
155 Ext.form.FieldSet.superclass.onExpand.call(this, doAnim, animArg);
\r
158 <div id="method-Ext.form.FieldSet-onCheckClick"></div>/**
\r
159 * This function is called by the fieldset's checkbox when it is toggled (only applies when
\r
160 * checkboxToggle = true). This method should never be called externally, but can be
\r
161 * overridden to provide custom behavior when the checkbox is toggled if needed.
\r
163 onCheckClick : function(){
\r
164 this[this.checkbox.dom.checked ? 'expand' : 'collapse']();
\r
167 <div id="cfg-Ext.form.FieldSet-activeItem"></div>/**
\r
168 * @cfg {String/Number} activeItem
\r
171 <div id="cfg-Ext.form.FieldSet-applyTo"></div>/**
\r
172 * @cfg {Mixed} applyTo
\r
175 <div id="cfg-Ext.form.FieldSet-bodyBorder"></div>/**
\r
176 * @cfg {Boolean} bodyBorder
\r
179 <div id="cfg-Ext.form.FieldSet-border"></div>/**
\r
180 * @cfg {Boolean} border
\r
183 <div id="cfg-Ext.form.FieldSet-bufferResize"></div>/**
\r
184 * @cfg {Boolean/Number} bufferResize
\r
187 <div id="cfg-Ext.form.FieldSet-collapseFirst"></div>/**
\r
188 * @cfg {Boolean} collapseFirst
\r
191 <div id="cfg-Ext.form.FieldSet-defaultType"></div>/**
\r
192 * @cfg {String} defaultType
\r
195 <div id="cfg-Ext.form.FieldSet-disabledClass"></div>/**
\r
196 * @cfg {String} disabledClass
\r
199 <div id="cfg-Ext.form.FieldSet-elements"></div>/**
\r
200 * @cfg {String} elements
\r
203 <div id="cfg-Ext.form.FieldSet-floating"></div>/**
\r
204 * @cfg {Boolean} floating
\r
207 <div id="cfg-Ext.form.FieldSet-footer"></div>/**
\r
208 * @cfg {Boolean} footer
\r
211 <div id="cfg-Ext.form.FieldSet-frame"></div>/**
\r
212 * @cfg {Boolean} frame
\r
215 <div id="cfg-Ext.form.FieldSet-header"></div>/**
\r
216 * @cfg {Boolean} header
\r
219 <div id="cfg-Ext.form.FieldSet-headerAsText"></div>/**
\r
220 * @cfg {Boolean} headerAsText
\r
223 <div id="cfg-Ext.form.FieldSet-hideCollapseTool"></div>/**
\r
224 * @cfg {Boolean} hideCollapseTool
\r
227 <div id="cfg-Ext.form.FieldSet-iconCls"></div>/**
\r
228 * @cfg {String} iconCls
\r
231 <div id="cfg-Ext.form.FieldSet-shadow"></div>/**
\r
232 * @cfg {Boolean/String} shadow
\r
235 <div id="cfg-Ext.form.FieldSet-shadowOffset"></div>/**
\r
236 * @cfg {Number} shadowOffset
\r
239 <div id="cfg-Ext.form.FieldSet-shim"></div>/**
\r
240 * @cfg {Boolean} shim
\r
243 <div id="cfg-Ext.form.FieldSet-tbar"></div>/**
\r
244 * @cfg {Object/Array} tbar
\r
247 <div id="cfg-Ext.form.FieldSet-tools"></div>/**
\r
248 * @cfg {Array} tools
\r
251 <div id="cfg-Ext.form.FieldSet-toolTemplate"></div>/**
\r
252 * @cfg {Ext.Template/Ext.XTemplate} toolTemplate
\r
255 <div id="cfg-Ext.form.FieldSet-xtype"></div>/**
\r
256 * @cfg {String} xtype
\r
259 <div id="prop-Ext.form.FieldSet-header"></div>/**
\r
263 <div id="prop-Ext.form.FieldSet-footer"></div>/**
\r
267 <div id="method-Ext.form.FieldSet-focus"></div>/**
\r
271 <div id="method-Ext.form.FieldSet-getBottomToolbar"></div>/**
\r
272 * @method getBottomToolbar
\r
275 <div id="method-Ext.form.FieldSet-getTopToolbar"></div>/**
\r
276 * @method getTopToolbar
\r
279 <div id="method-Ext.form.FieldSet-setIconClass"></div>/**
\r
280 * @method setIconClass
\r
283 <div id="event-Ext.form.FieldSet-activate"></div>/**
\r
287 <div id="event-Ext.form.FieldSet-beforeclose"></div>/**
\r
288 * @event beforeclose
\r
291 <div id="event-Ext.form.FieldSet-bodyresize"></div>/**
\r
292 * @event bodyresize
\r
295 <div id="event-Ext.form.FieldSet-close"></div>/**
\r
299 <div id="event-Ext.form.FieldSet-deactivate"></div>/**
\r
300 * @event deactivate
\r
304 Ext.reg('fieldset', Ext.form.FieldSet);
\r