Upgrade to ExtJS 4.0.7 - Released 10/19/2011
[extjs.git] / docs / source / FieldSet.html
index bffc0eb..f62371b 100644 (file)
@@ -1,17 +1,33 @@
-<!DOCTYPE html><html><head><title>Sencha Documentation Project</title><link rel="stylesheet" href="../reset.css" type="text/css"><link rel="stylesheet" href="../prettify.css" type="text/css"><link rel="stylesheet" href="../prettify_sa.css" type="text/css"><script type="text/javascript" src="../prettify.js"></script></head><body onload="prettyPrint()"><pre class="prettyprint"><pre><span id='Ext-form.FieldSet-method-constructor'><span id='Ext-form.FieldSet'>/**
-</span></span> * @class Ext.form.FieldSet
- * @extends Ext.container.Container
- * 
+<!DOCTYPE html>
+<html>
+<head>
+  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+  <title>The source code</title>
+  <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
+  <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
+  <style type="text/css">
+    .highlight { display: block; background-color: #ddd; }
+  </style>
+  <script type="text/javascript">
+    function highlight() {
+      document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
+    }
+  </script>
+</head>
+<body onload="prettyPrint(); highlight();">
+  <pre class="prettyprint lang-js"><span id='Ext-form-FieldSet'>/**
+</span> * @docauthor Jason Johnston &lt;jason@sencha.com&gt;
+ *
  * A container for grouping sets of fields, rendered as a HTML `fieldset` element. The {@link #title}
  * config will be rendered as the fieldset's `legend`.
- * 
+ *
  * While FieldSets commonly contain simple groups of fields, they are general {@link Ext.container.Container Containers}
  * and may therefore contain any type of components in their {@link #items}, including other nested containers.
  * The default {@link #layout} for the FieldSet's items is `'anchor'`, but it can be configured to use any other
  * layout type.
- * 
+ *
  * FieldSets may also be collapsed if configured to do so; this can be done in two ways:
- * 
+ *
  * 1. Set the {@link #collapsible} config to true; this will result in a collapse button being rendered next to
  *    the {@link #title legend title}, or:
  * 2. Set the {@link #checkboxToggle} config to true; this is similar to using {@link #collapsible} but renders
  *    checkbox is checked and collapsed when it is unchecked. The checkbox will also be included in the
  *    {@link Ext.form.Basic#submit form submit parameters} using the {@link #checkboxName} as its parameter name.
  *
- * {@img Ext.form.FieldSet/Ext.form.FieldSet.png Ext.form.FieldSet component}
+ * # Example usage
  *
- * ## Example usage
- * 
+ *     @example
  *     Ext.create('Ext.form.Panel', {
  *         title: 'Simple Form with FieldSets',
  *         labelWidth: 75, // label settings here cascade unless overridden
  *             }]
  *         }]
  *     });
- * 
- * @constructor
- * Create a new FieldSet
- * @param {Object} config Configuration options
- * @xtype fieldset
- * @docauthor Jason Johnston &lt;jason@sencha.com&gt;
  */
 Ext.define('Ext.form.FieldSet', {
     extend: 'Ext.container.Container',
     alias: 'widget.fieldset',
     uses: ['Ext.form.field.Checkbox', 'Ext.panel.Tool', 'Ext.layout.container.Anchor', 'Ext.layout.component.FieldSet'],
 
-<span id='Ext-form.FieldSet-cfg-title'>    /**
+<span id='Ext-form-FieldSet-cfg-title'>    /**
 </span>     * @cfg {String} title
      * A title to be displayed in the fieldset's legend. May contain HTML markup.
      */
 
-<span id='Ext-form.FieldSet-cfg-checkboxToggle'>    /**
-</span>     * @cfg {Boolean} checkboxToggle
-     * Set to &lt;tt&gt;true&lt;/tt&gt; to render a checkbox into the fieldset frame just
-     * in front of the legend to expand/collapse the fieldset when the checkbox is toggled. (defaults
-     * to &lt;tt&gt;false&lt;/tt&gt;). This checkbox will be included in form submits using the {@link #checkboxName}.
+<span id='Ext-form-FieldSet-cfg-checkboxToggle'>    /**
+</span>     * @cfg {Boolean} [checkboxToggle=false]
+     * Set to true to render a checkbox into the fieldset frame just in front of the legend to expand/collapse the
+     * fieldset when the checkbox is toggled.. This checkbox will be included in form submits using
+     * the {@link #checkboxName}.
      */
 
-<span id='Ext-form.FieldSet-cfg-checkboxName'>    /**
+<span id='Ext-form-FieldSet-cfg-checkboxName'>    /**
 </span>     * @cfg {String} checkboxName
-     * The name to assign to the fieldset's checkbox if &lt;tt&gt;{@link #checkboxToggle} = true&lt;/tt&gt;
-     * (defaults to &lt;tt&gt;'[fieldset id]-checkbox'&lt;/tt&gt;).
+     * The name to assign to the fieldset's checkbox if {@link #checkboxToggle} = true
+     * (defaults to '[fieldset id]-checkbox').
      */
 
-<span id='Ext-form.FieldSet-cfg-collapsible'>    /**
-</span>     * @cfg {Boolean} collapsible
-     * Set to &lt;tt&gt;true&lt;/tt&gt; to make the fieldset collapsible and have the expand/collapse toggle button automatically
-     * rendered into the legend element, &lt;tt&gt;false&lt;/tt&gt; to keep the fieldset statically sized with no collapse
-     * button (defaults to &lt;tt&gt;false&lt;/tt&gt;). Another option is to configure &lt;tt&gt;{@link #checkboxToggle}&lt;/tt&gt;.
-     * Use the {@link #collapsed} config to collapse the fieldset by default.
+<span id='Ext-form-FieldSet-cfg-collapsible'>    /**
+</span>     * @cfg {Boolean} [collapsible=false]
+     * Set to true to make the fieldset collapsible and have the expand/collapse toggle button automatically rendered
+     * into the legend element, false to keep the fieldset statically sized with no collapse button.
+     * Another option is to configure {@link #checkboxToggle}. Use the {@link #collapsed} config to collapse the
+     * fieldset by default.
      */
 
-<span id='Ext-form.FieldSet-cfg-collapsed'>    /**
+<span id='Ext-form-FieldSet-cfg-collapsed'>    /**
 </span>     * @cfg {Boolean} collapsed
-     * Set to &lt;tt&gt;true&lt;/tt&gt; to render the fieldset as collapsed by default. If {@link #checkboxToggle} is specified,
-     * the checkbox will also be unchecked by default.
+     * Set to true to render the fieldset as collapsed by default. If {@link #checkboxToggle} is specified, the checkbox
+     * will also be unchecked by default.
      */
     collapsed: false,
 
-<span id='Ext-form.FieldSet-property-legend'>    /**
-</span>     * @property legend
-     * @type Ext.Component
-     * The component for the fieldset's legend. Will only be defined if the configuration requires a legend
-     * to be created, by setting the {@link #title} or {@link #checkboxToggle} options.
+<span id='Ext-form-FieldSet-property-legend'>    /**
+</span>     * @property {Ext.Component} legend
+     * The component for the fieldset's legend. Will only be defined if the configuration requires a legend to be
+     * created, by setting the {@link #title} or {@link #checkboxToggle} options.
      */
 
-<span id='Ext-form.FieldSet-cfg-baseCls'>    /**
-</span>     * @cfg {String} baseCls The base CSS class applied to the fieldset (defaults to &lt;tt&gt;'x-fieldset'&lt;/tt&gt;).
+<span id='Ext-form-FieldSet-cfg-baseCls'>    /**
+</span>     * @cfg {String} [baseCls='x-fieldset']
+     * The base CSS class applied to the fieldset.
      */
     baseCls: Ext.baseCSSPrefix + 'fieldset',
 
-<span id='Ext-form.FieldSet-cfg-layout'>    /**
-</span>     * @cfg {String} layout The {@link Ext.container.Container#layout} for the fieldset's immediate child items.
-     * Defaults to &lt;tt&gt;'anchor'&lt;/tt&gt;.
+<span id='Ext-form-FieldSet-cfg-layout'>    /**
+</span>     * @cfg {String} layout
+     * The {@link Ext.container.Container#layout} for the fieldset's immediate child items.
      */
     layout: 'anchor',
 
@@ -136,8 +145,8 @@ Ext.define('Ext.form.FieldSet', {
     // No aria role necessary as fieldset has its own recognized semantics
     ariaRole: '',
 
-    renderTpl: ['&lt;div class=&quot;{baseCls}-body&quot;&gt;&lt;/div&gt;'],
-    
+    renderTpl: ['&lt;div id=&quot;{id}-body&quot; class=&quot;{baseCls}-body&quot;&gt;&lt;/div&gt;'],
+
     maskOnDisable: false,
 
     getElConfig: function(){
@@ -153,10 +162,8 @@ Ext.define('Ext.form.FieldSet', {
         // Create the Legend component if needed
         me.initLegend();
 
-        // Add body el selector
-        Ext.applyIf(me.renderSelectors, {
-            body: '.' + baseCls + '-body'
-        });
+        // Add body el
+        me.addChildEls('body');
 
         if (me.collapsed) {
             me.addCls(baseCls + '-collapsed');
@@ -171,7 +178,7 @@ Ext.define('Ext.form.FieldSet', {
         this.initLegend();
     },
 
-<span id='Ext-form.FieldSet-method-initLegend'>    /**
+<span id='Ext-form-FieldSet-method-initLegend'>    /**
 </span>     * @private
      * Initialize and render the legend component if necessary
      */
@@ -199,8 +206,23 @@ Ext.define('Ext.form.FieldSet', {
             legend = me.legend = Ext.create('Ext.container.Container', {
                 baseCls: me.baseCls + '-header',
                 ariaRole: '',
+                ownerCt: this,
                 getElConfig: function(){
-                    return {tag: 'legend', cls: this.baseCls};
+                    var result = {
+                        tag: 'legend',
+                        cls: this.baseCls
+                    };
+
+                    // Gecko3 will kick every &lt;div&gt; out of &lt;legend&gt; and mess up every thing.
+                    // So here we change every &lt;div&gt; into &lt;span&gt;s. Therefore the following
+                    // clearer is not needed and since div introduces a lot of subsequent
+                    // problems, it is actually harmful.
+                    if (!Ext.isGecko3) {
+                        result.children = [{
+                            cls: Ext.baseCSSPrefix + 'clear'
+                        }];
+                    }
+                    return result;
                 },
                 items: legendItems
             });
@@ -212,40 +234,52 @@ Ext.define('Ext.form.FieldSet', {
         }
     },
 
-<span id='Ext-form.FieldSet-method-createTitleCmp'>    /**
-</span>     * @protected
-     * Creates the legend title component. This is only called internally, but could be overridden in subclasses
-     * to customize the title component.
+<span id='Ext-form-FieldSet-method-createTitleCmp'>    /**
+</span>     * Creates the legend title component. This is only called internally, but could be overridden in subclasses to
+     * customize the title component.
      * @return Ext.Component
+     * @protected
      */
     createTitleCmp: function() {
         var me = this;
         me.titleCmp = Ext.create('Ext.Component', {
             html: me.title,
+            getElConfig: function() {
+                return {
+                    tag: Ext.isGecko3 ? 'span' : 'div',
+                    cls: me.titleCmp.cls,
+                    id: me.titleCmp.id
+                };
+            },
             cls: me.baseCls + '-header-text'
         });
         return me.titleCmp;
-        
     },
 
-<span id='Ext-form.FieldSet-property-checkboxCmp'>    /**
-</span>     * @property checkboxCmp
-     * @type Ext.form.field.Checkbox
+<span id='Ext-form-FieldSet-property-checkboxCmp'>    /**
+</span>     * @property {Ext.form.field.Checkbox} checkboxCmp
      * Refers to the {@link Ext.form.field.Checkbox} component that is added next to the title in the legend. Only
-     * populated if the fieldset is configured with &lt;tt&gt;{@link #checkboxToggle}:true&lt;/tt&gt;.
+     * populated if the fieldset is configured with {@link #checkboxToggle}:true.
      */
 
-<span id='Ext-form.FieldSet-method-createCheckboxCmp'>    /**
-</span>     * @protected
-     * Creates the checkbox component. This is only called internally, but could be overridden in subclasses
-     * to customize the checkbox's configuration or even return an entirely different component type.
+<span id='Ext-form-FieldSet-method-createCheckboxCmp'>    /**
+</span>     * Creates the checkbox component. This is only called internally, but could be overridden in subclasses to
+     * customize the checkbox's configuration or even return an entirely different component type.
      * @return Ext.Component
+     * @protected
      */
     createCheckboxCmp: function() {
         var me = this,
             suffix = '-checkbox';
-            
+
         me.checkboxCmp = Ext.create('Ext.form.field.Checkbox', {
+            getElConfig: function() {
+                return {
+                    tag: Ext.isGecko3 ? 'span' : 'div',
+                    id: me.checkboxCmp.id,
+                    cls: me.checkboxCmp.cls
+                };
+            },
             name: me.checkboxName || me.id + suffix,
             cls: me.baseCls + '-header' + suffix,
             checked: !me.collapsed,
@@ -257,30 +291,36 @@ Ext.define('Ext.form.FieldSet', {
         return me.checkboxCmp;
     },
 
-<span id='Ext-form.FieldSet-property-toggleCmp'>    /**
-</span>     * @property toggleCmp
-     * @type Ext.panel.Tool
-     * Refers to the {@link Ext.panel.Tool} component that is added as the collapse/expand button next
-     * to the title in the legend. Only populated if the fieldset is configured with &lt;tt&gt;{@link #collapsible}:true&lt;/tt&gt;.
+<span id='Ext-form-FieldSet-property-toggleCmp'>    /**
+</span>     * @property {Ext.panel.Tool} toggleCmp
+     * Refers to the {@link Ext.panel.Tool} component that is added as the collapse/expand button next to the title in
+     * the legend. Only populated if the fieldset is configured with {@link #collapsible}:true.
      */
 
-<span id='Ext-form.FieldSet-method-createToggleCmp'>    /**
-</span>     * @protected
-     * Creates the toggle button component. This is only called internally, but could be overridden in
-     * subclasses to customize the toggle component.
+<span id='Ext-form-FieldSet-method-createToggleCmp'>    /**
+</span>     * Creates the toggle button component. This is only called internally, but could be overridden in subclasses to
+     * customize the toggle component.
      * @return Ext.Component
+     * @protected
      */
     createToggleCmp: function() {
         var me = this;
         me.toggleCmp = Ext.create('Ext.panel.Tool', {
+            getElConfig: function() {
+                return {
+                    tag: Ext.isGecko3 ? 'span' : 'div',
+                    id: me.toggleCmp.id,
+                    cls: me.toggleCmp.cls
+                };
+            },
             type: 'toggle',
             handler: me.toggle,
             scope: me
         });
         return me.toggleCmp;
     },
-    
-<span id='Ext-form.FieldSet-method-setTitle'>    /**
+
+<span id='Ext-form-FieldSet-method-setTitle'>    /**
 </span>     * Sets the title of this fieldset
      * @param {String} title The new title
      * @return {Ext.form.FieldSet} this
@@ -292,16 +332,16 @@ Ext.define('Ext.form.FieldSet', {
         me.titleCmp.update(title);
         return me;
     },
-    
+
     getTargetEl : function() {
         return this.body || this.frameBody || this.el;
     },
-    
+
     getContentTarget: function() {
         return this.body;
     },
-    
-<span id='Ext-form.FieldSet-method-getRefItems'>    /**
+
+<span id='Ext-form-FieldSet-method-getRefItems'>    /**
 </span>     * @private
      * Include the legend component in the items for ComponentQuery
      */
@@ -319,15 +359,15 @@ Ext.define('Ext.form.FieldSet', {
         return refItems;
     },
 
-<span id='Ext-form.FieldSet-method-expand'>    /**
+<span id='Ext-form-FieldSet-method-expand'>    /**
 </span>     * Expands the fieldset.
      * @return {Ext.form.FieldSet} this
      */
     expand : function(){
         return this.setExpanded(true);
     },
-    
-<span id='Ext-form.FieldSet-method-collapse'>    /**
+
+<span id='Ext-form-FieldSet-method-collapse'>    /**
 </span>     * Collapses the fieldset.
      * @return {Ext.form.FieldSet} this
      */
@@ -335,39 +375,43 @@ Ext.define('Ext.form.FieldSet', {
         return this.setExpanded(false);
     },
 
-<span id='Ext-form.FieldSet-method-setExpanded'>    /**
+<span id='Ext-form-FieldSet-method-setExpanded'>    /**
 </span>     * @private Collapse or expand the fieldset
      */
     setExpanded: function(expanded) {
         var me = this,
-            checkboxCmp = me.checkboxCmp,
-            toggleCmp = me.toggleCmp;
+            checkboxCmp = me.checkboxCmp;
 
         expanded = !!expanded;
-        
+
         if (checkboxCmp) {
             checkboxCmp.setValue(expanded);
         }
-        
+
         if (expanded) {
             me.removeCls(me.baseCls + '-collapsed');
         } else {
             me.addCls(me.baseCls + '-collapsed');
         }
         me.collapsed = !expanded;
+        if (expanded) {
+            // ensure subitems will get rendered and layed out when expanding
+            me.getComponentLayout().childrenChanged = true;
+        }
         me.doComponentLayout();
         return me;
     },
 
-<span id='Ext-form.FieldSet-method-toggle'>    /**
+<span id='Ext-form-FieldSet-method-toggle'>    /**
 </span>     * Toggle the fieldset's collapsed state to the opposite of what it is currently
      */
     toggle: function() {
         this.setExpanded(!!this.collapsed);
     },
 
-<span id='Ext-form.FieldSet-method-onCheckChange'>    /**
-</span>     * @private Handle changes in the checkbox checked state
+<span id='Ext-form-FieldSet-method-onCheckChange'>    /**
+</span>     * @private
+     * Handle changes in the checkbox checked state
      */
     onCheckChange: function(cmp, checked) {
         this.setExpanded(checked);
@@ -381,4 +425,6 @@ Ext.define('Ext.form.FieldSet', {
         this.callParent();
     }
 });
-</pre></pre></body></html>
\ No newline at end of file
+</pre>
+</body>
+</html>