3 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
4 <title>The source code</title>
5 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
6 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
8 <body onload="prettyPrint();">
9 <pre class="prettyprint lang-js">/*!
10 * Ext JS Library 3.2.2
11 * Copyright(c) 2006-2010 Ext JS, Inc.
13 * http://www.extjs.com/license
15 <div id="cls-Ext.form.Radio"></div>/**
16 * @class Ext.form.Radio
17 * @extends Ext.form.Checkbox
18 * Single radio field. Same as Checkbox, but provided as a convenience for automatically setting the input type.
19 * Radio grouping is handled automatically by the browser if you give each radio in a group the same name.
22 * @param {Object} config Configuration options
25 Ext.form.Radio = Ext.extend(Ext.form.Checkbox, {
28 <div id="method-Ext.form.Radio-markInvalid"></div>/**
29 * Overridden and disabled. The editor element does not support standard valid/invalid marking. @hide
32 markInvalid : Ext.emptyFn,
33 <div id="method-Ext.form.Radio-clearInvalid"></div>/**
34 * Overridden and disabled. The editor element does not support standard valid/invalid marking. @hide
37 clearInvalid : Ext.emptyFn,
39 <div id="method-Ext.form.Radio-getGroupValue"></div>/**
40 * If this radio is part of a group, it will return the selected value
43 getGroupValue : function(){
44 var p = this.el.up('form') || Ext.getBody();
45 var c = p.child('input[name='+this.el.dom.name+']:checked', true);
46 return c ? c.value : null;
51 if(this.el.dom.checked != this.checked){
52 var els = this.getCheckEl().select('input[name=' + this.el.dom.name + ']');
53 els.each(function(el){
54 if(el.dom.id == this.id){
57 Ext.getCmp(el.dom.id).setValue(false);
63 <div id="method-Ext.form.Radio-setValue"></div>/**
64 * Sets either the checked/unchecked status of this Radio, or, if a string value
65 * is passed, checks a sibling Radio of the same name whose value is the value specified.
66 * @param value {String/Boolean} Checked value, or the value of the sibling radio button to check.
67 * @return {Ext.form.Field} this
69 setValue : function(v){
70 if (typeof v == 'boolean') {
71 Ext.form.Radio.superclass.setValue.call(this, v);
72 } else if (this.rendered) {
73 var r = this.getCheckEl().child('input[name=' + this.el.dom.name + '][value=' + v + ']', true);
75 Ext.getCmp(r.id).setValue(true);
82 getCheckEl: function(){
84 return this.el.up('.x-form-radio-group')
86 return this.el.up('form') || Ext.getBody();
89 Ext.reg('radio', Ext.form.Radio);