3 <title>The source code</title>
\r
4 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
\r
5 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
\r
7 <body onload="prettyPrint();">
\r
8 <pre class="prettyprint lang-js"><div id="cls-Ext.form.FieldSet"></div>/**
\r
9 * @class Ext.form.FieldSet
\r
10 * @extends Ext.Panel
\r
11 * Standard container used for grouping items within a {@link Ext.form.FormPanel form}.
\r
13 var form = new Ext.FormPanel({
\r
14 title: 'Simple Form with FieldSets',
\r
15 labelWidth: 75, // label settings here cascade unless overridden
\r
16 url: 'save-form.php',
\r
18 bodyStyle:'padding:5px 5px 0',
\r
20 renderTo: document.body,
\r
21 layout:'column', // arrange items in columns
\r
22 defaults: { // defaults applied to items
\r
25 bodyStyle: 'padding:4px'
\r
28 // Fieldset in Column 1
\r
31 title: 'Fieldset 1',
\r
35 anchor: '-20' // leave room for error icon
\r
37 defaultType: 'textfield',
\r
39 fieldLabel: 'Field 1'
\r
41 fieldLabel: 'Field 2'
\r
43 fieldLabel: 'Field 3'
\r
47 // Fieldset in Column 2 - Panel inside
\r
49 title: 'Show Panel', // title, header, or checkboxToggle creates fieldset header
\r
52 checkboxToggle: true,
\r
53 collapsed: true, // fieldset initially collapsed
\r
58 title: 'Panel inside a fieldset',
\r
66 * @param {Object} config Configuration options
\r
69 Ext.form.FieldSet = Ext.extend(Ext.Panel, {
\r
70 <div id="cfg-Ext.form.FieldSet-checkboxToggle"></div>/**
\r
71 * @cfg {Mixed} checkboxToggle <tt>true</tt> to render a checkbox into the fieldset frame just
\r
72 * in front of the legend to expand/collapse the fieldset when the checkbox is toggled. (defaults
\r
73 * to <tt>false</tt>).
\r
74 * <p>A {@link Ext.DomHelper DomHelper} element spec may also be specified to create the checkbox.
\r
75 * If <tt>true</tt> is specified, the default DomHelper config object used to create the element
\r
76 * is:</p><pre><code>
\r
77 * {tag: 'input', type: 'checkbox', name: this.checkboxName || this.id+'-checkbox'}
\r
80 <div id="cfg-Ext.form.FieldSet-checkboxName"></div>/**
\r
81 * @cfg {String} checkboxName The name to assign to the fieldset's checkbox if <tt>{@link #checkboxToggle} = true</tt>
\r
82 * (defaults to <tt>'[checkbox id]-checkbox'</tt>).
\r
84 <div id="cfg-Ext.form.FieldSet-collapsible"></div>/**
\r
85 * @cfg {Boolean} collapsible
\r
86 * <tt>true</tt> to make the fieldset collapsible and have the expand/collapse toggle button automatically
\r
87 * rendered into the legend element, <tt>false</tt> to keep the fieldset statically sized with no collapse
\r
88 * button (defaults to <tt>false</tt>). Another option is to configure <tt>{@link #checkboxToggle}</tt>.
\r
90 <div id="cfg-Ext.form.FieldSet-labelWidth"></div>/**
\r
91 * @cfg {Number} labelWidth The width of labels. This property cascades to child containers.
\r
93 <div id="cfg-Ext.form.FieldSet-itemCls"></div>/**
\r
94 * @cfg {String} itemCls A css class to apply to the <tt>x-form-item</tt> of fields (see
\r
95 * {@link Ext.layout.FormLayout}.{@link Ext.layout.FormLayout#fieldTpl fieldTpl} for details).
\r
96 * This property cascades to child containers.
\r
98 <div id="cfg-Ext.form.FieldSet-baseCls"></div>/**
\r
99 * @cfg {String} baseCls The base CSS class applied to the fieldset (defaults to <tt>'x-fieldset'</tt>).
\r
101 baseCls : 'x-fieldset',
\r
102 <div id="cfg-Ext.form.FieldSet-layout"></div>/**
\r
103 * @cfg {String} layout The {@link Ext.Container#layout} to use inside the fieldset (defaults to <tt>'form'</tt>).
\r
106 <div id="cfg-Ext.form.FieldSet-animCollapse"></div>/**
\r
107 * @cfg {Boolean} animCollapse
\r
108 * <tt>true</tt> to animate the transition when the panel is collapsed, <tt>false</tt> to skip the
\r
109 * animation (defaults to <tt>false</tt>).
\r
111 animCollapse : false,
\r
114 onRender : function(ct, position){
\r
116 this.el = document.createElement('fieldset');
\r
117 this.el.id = this.id;
\r
118 if (this.title || this.header || this.checkboxToggle) {
\r
119 this.el.appendChild(document.createElement('legend')).className = 'x-fieldset-header';
\r
123 Ext.form.FieldSet.superclass.onRender.call(this, ct, position);
\r
125 if(this.checkboxToggle){
\r
126 var o = typeof this.checkboxToggle == 'object' ?
\r
127 this.checkboxToggle :
\r
128 {tag: 'input', type: 'checkbox', name: this.checkboxName || this.id+'-checkbox'};
\r
129 this.checkbox = this.header.insertFirst(o);
\r
130 this.checkbox.dom.checked = !this.collapsed;
\r
131 this.mon(this.checkbox, 'click', this.onCheckClick, this);
\r
136 onCollapse : function(doAnim, animArg){
\r
138 this.checkbox.dom.checked = false;
\r
140 Ext.form.FieldSet.superclass.onCollapse.call(this, doAnim, animArg);
\r
145 onExpand : function(doAnim, animArg){
\r
147 this.checkbox.dom.checked = true;
\r
149 Ext.form.FieldSet.superclass.onExpand.call(this, doAnim, animArg);
\r
152 <div id="method-Ext.form.FieldSet-onCheckClick"></div>/**
\r
153 * This function is called by the fieldset's checkbox when it is toggled (only applies when
\r
154 * checkboxToggle = true). This method should never be called externally, but can be
\r
155 * overridden to provide custom behavior when the checkbox is toggled if needed.
\r
157 onCheckClick : function(){
\r
158 this[this.checkbox.dom.checked ? 'expand' : 'collapse']();
\r
161 <div id="cfg-Ext.form.FieldSet-activeItem"></div>/**
\r
162 * @cfg {String/Number} activeItem
\r
165 <div id="cfg-Ext.form.FieldSet-applyTo"></div>/**
\r
166 * @cfg {Mixed} applyTo
\r
169 <div id="cfg-Ext.form.FieldSet-bodyBorder"></div>/**
\r
170 * @cfg {Boolean} bodyBorder
\r
173 <div id="cfg-Ext.form.FieldSet-border"></div>/**
\r
174 * @cfg {Boolean} border
\r
177 <div id="cfg-Ext.form.FieldSet-bufferResize"></div>/**
\r
178 * @cfg {Boolean/Number} bufferResize
\r
181 <div id="cfg-Ext.form.FieldSet-collapseFirst"></div>/**
\r
182 * @cfg {Boolean} collapseFirst
\r
185 <div id="cfg-Ext.form.FieldSet-defaultType"></div>/**
\r
186 * @cfg {String} defaultType
\r
189 <div id="cfg-Ext.form.FieldSet-disabledClass"></div>/**
\r
190 * @cfg {String} disabledClass
\r
193 <div id="cfg-Ext.form.FieldSet-elements"></div>/**
\r
194 * @cfg {String} elements
\r
197 <div id="cfg-Ext.form.FieldSet-floating"></div>/**
\r
198 * @cfg {Boolean} floating
\r
201 <div id="cfg-Ext.form.FieldSet-footer"></div>/**
\r
202 * @cfg {Boolean} footer
\r
205 <div id="cfg-Ext.form.FieldSet-frame"></div>/**
\r
206 * @cfg {Boolean} frame
\r
209 <div id="cfg-Ext.form.FieldSet-header"></div>/**
\r
210 * @cfg {Boolean} header
\r
213 <div id="cfg-Ext.form.FieldSet-headerAsText"></div>/**
\r
214 * @cfg {Boolean} headerAsText
\r
217 <div id="cfg-Ext.form.FieldSet-hideCollapseTool"></div>/**
\r
218 * @cfg {Boolean} hideCollapseTool
\r
221 <div id="cfg-Ext.form.FieldSet-iconCls"></div>/**
\r
222 * @cfg {String} iconCls
\r
225 <div id="cfg-Ext.form.FieldSet-shadow"></div>/**
\r
226 * @cfg {Boolean/String} shadow
\r
229 <div id="cfg-Ext.form.FieldSet-shadowOffset"></div>/**
\r
230 * @cfg {Number} shadowOffset
\r
233 <div id="cfg-Ext.form.FieldSet-shim"></div>/**
\r
234 * @cfg {Boolean} shim
\r
237 <div id="cfg-Ext.form.FieldSet-tbar"></div>/**
\r
238 * @cfg {Object/Array} tbar
\r
241 <div id="cfg-Ext.form.FieldSet-tabTip"></div>/**
\r
242 * @cfg {String} tabTip
\r
245 <div id="cfg-Ext.form.FieldSet-titleCollapse"></div>/**
\r
246 * @cfg {Boolean} titleCollapse
\r
249 <div id="cfg-Ext.form.FieldSet-tools"></div>/**
\r
250 * @cfg {Array} tools
\r
253 <div id="cfg-Ext.form.FieldSet-toolTemplate"></div>/**
\r
254 * @cfg {Ext.Template/Ext.XTemplate} toolTemplate
\r
257 <div id="cfg-Ext.form.FieldSet-xtype"></div>/**
\r
258 * @cfg {String} xtype
\r
261 <div id="prop-Ext.form.FieldSet-header"></div>/**
\r
265 <div id="prop-Ext.form.FieldSet-footer"></div>/**
\r
269 <div id="method-Ext.form.FieldSet-focus"></div>/**
\r
273 <div id="method-Ext.form.FieldSet-getBottomToolbar"></div>/**
\r
274 * @method getBottomToolbar
\r
277 <div id="method-Ext.form.FieldSet-getTopToolbar"></div>/**
\r
278 * @method getTopToolbar
\r
281 <div id="method-Ext.form.FieldSet-setIconClass"></div>/**
\r
282 * @method setIconClass
\r
285 <div id="event-Ext.form.FieldSet-activate"></div>/**
\r
289 <div id="event-Ext.form.FieldSet-beforeclose"></div>/**
\r
290 * @event beforeclose
\r
293 <div id="event-Ext.form.FieldSet-bodyresize"></div>/**
\r
294 * @event bodyresize
\r
297 <div id="event-Ext.form.FieldSet-close"></div>/**
\r
301 <div id="event-Ext.form.FieldSet-deactivate"></div>/**
\r
302 * @event deactivate
\r
306 Ext.reg('fieldset', Ext.form.FieldSet);
\r