Upgrade to ExtJS 3.0.0 - Released 07/06/2009
[extjs.git] / docs / source / Radio.html
diff --git a/docs/source/Radio.html b/docs/source/Radio.html
new file mode 100644 (file)
index 0000000..f551a2b
--- /dev/null
@@ -0,0 +1,85 @@
+<html>\r
+<head>\r
+  <title>The source code</title>\r
+    <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />\r
+    <script type="text/javascript" src="../resources/prettify/prettify.js"></script>\r
+</head>\r
+<body  onload="prettyPrint();">\r
+    <pre class="prettyprint lang-js"><div id="cls-Ext.form.Radio"></div>/**
+ * @class Ext.form.Radio
+ * @extends Ext.form.Checkbox
+ * Single radio field.  Same as Checkbox, but provided as a convenience for automatically setting the input type.
+ * Radio grouping is handled automatically by the browser if you give each radio in a group the same name.
+ * @constructor
+ * Creates a new Radio
+ * @param {Object} config Configuration options
+ * @xtype radio
+ */
+Ext.form.Radio = Ext.extend(Ext.form.Checkbox, {
+    inputType: 'radio',
+
+    <div id="method-Ext.form.Radio-markInvalid"></div>/**
+     * Overridden and disabled. The editor element does not support standard valid/invalid marking. @hide
+     * @method
+     */
+    markInvalid : Ext.emptyFn,
+    <div id="method-Ext.form.Radio-clearInvalid"></div>/**
+     * Overridden and disabled. The editor element does not support standard valid/invalid marking. @hide
+     * @method
+     */
+    clearInvalid : Ext.emptyFn,
+
+    <div id="method-Ext.form.Radio-getGroupValue"></div>/**
+     * If this radio is part of a group, it will return the selected value
+     * @return {String}
+     */
+    getGroupValue : function(){
+       var p = this.el.up('form') || Ext.getBody();
+        var c = p.child('input[name='+this.el.dom.name+']:checked', true);
+        return c ? c.value : null;
+    },
+
+    // private
+    onClick : function(){
+       if(this.el.dom.checked != this.checked){
+                       var els = this.getCheckEl().select('input[name=' + this.el.dom.name + ']');
+                       els.each(function(el){
+                               if(el.dom.id == this.id){
+                                       this.setValue(true);
+                               }else{
+                                       Ext.getCmp(el.dom.id).setValue(false);
+                               }
+                       }, this);
+               }
+    },
+
+    <div id="method-Ext.form.Radio-setValue"></div>/**
+     * Sets either the checked/unchecked status of this Radio, or, if a string value
+     * is passed, checks a sibling Radio of the same name whose value is the value specified.
+     * @param value {String/Boolean} Checked value, or the value of the sibling radio button to check.
+     * @return {Ext.form.Field} this
+     */
+    setValue : function(v){
+       if (typeof v == 'boolean') {
+            Ext.form.Radio.superclass.setValue.call(this, v);
+        } else {
+            var r = this.getCheckEl().child('input[name=' + this.el.dom.name + '][value=' + v + ']', true);
+            if(r){
+                Ext.getCmp(r.id).setValue(true);
+            }
+        }
+        return this;
+    },
+    
+    // private
+    getCheckEl: function(){
+        if(this.inGroup){
+            return this.el.up('.x-form-radio-group')
+        }
+        return this.el.up('form') || Ext.getBody();
+    }
+});
+Ext.reg('radio', Ext.form.Radio);
+</pre>    \r
+</body>\r
+</html>
\ No newline at end of file