3 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
\r
4 <title>The source code</title>
\r
5 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
\r
6 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
\r
8 <body onload="prettyPrint();">
\r
9 <pre class="prettyprint lang-js"><div id="cls-Ext.form.Radio"></div>/**
10 * @class Ext.form.Radio
11 * @extends Ext.form.Checkbox
12 * Single radio field. Same as Checkbox, but provided as a convenience for automatically setting the input type.
13 * Radio grouping is handled automatically by the browser if you give each radio in a group the same name.
16 * @param {Object} config Configuration options
19 Ext.form.Radio = Ext.extend(Ext.form.Checkbox, {
22 <div id="method-Ext.form.Radio-markInvalid"></div>/**
23 * Overridden and disabled. The editor element does not support standard valid/invalid marking. @hide
26 markInvalid : Ext.emptyFn,
27 <div id="method-Ext.form.Radio-clearInvalid"></div>/**
28 * Overridden and disabled. The editor element does not support standard valid/invalid marking. @hide
31 clearInvalid : Ext.emptyFn,
33 <div id="method-Ext.form.Radio-getGroupValue"></div>/**
34 * If this radio is part of a group, it will return the selected value
37 getGroupValue : function(){
38 var p = this.el.up('form') || Ext.getBody();
39 var c = p.child('input[name='+this.el.dom.name+']:checked', true);
40 return c ? c.value : null;
45 if(this.el.dom.checked != this.checked){
46 var els = this.getCheckEl().select('input[name=' + this.el.dom.name + ']');
47 els.each(function(el){
48 if(el.dom.id == this.id){
51 Ext.getCmp(el.dom.id).setValue(false);
57 <div id="method-Ext.form.Radio-setValue"></div>/**
58 * Sets either the checked/unchecked status of this Radio, or, if a string value
59 * is passed, checks a sibling Radio of the same name whose value is the value specified.
60 * @param value {String/Boolean} Checked value, or the value of the sibling radio button to check.
61 * @return {Ext.form.Field} this
63 setValue : function(v){
64 if (typeof v == 'boolean') {
65 Ext.form.Radio.superclass.setValue.call(this, v);
67 var r = this.getCheckEl().child('input[name=' + this.el.dom.name + '][value=' + v + ']', true);
69 Ext.getCmp(r.id).setValue(true);
76 getCheckEl: function(){
78 return this.el.up('.x-form-radio-group')
80 return this.el.up('form') || Ext.getBody();
83 Ext.reg('radio', Ext.form.Radio);