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.3.1
11 * Copyright(c) 2006-2010 Sencha Inc.
12 * licensing@sencha.com
13 * http://www.sencha.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;
49 <div id="method-Ext.form.Radio-setValue"></div>/**
50 * Sets either the checked/unchecked status of this Radio, or, if a string value
51 * is passed, checks a sibling Radio of the same name whose value is the value specified.
52 * @param value {String/Boolean} Checked value, or the value of the sibling radio button to check.
53 * @return {Ext.form.Field} this
55 setValue : function(v){
59 if (typeof v == 'boolean') {
60 Ext.form.Radio.superclass.setValue.call(this, v);
61 } else if (this.rendered) {
62 checkEl = this.getCheckEl();
63 radio = checkEl.child('input[name=' + this.el.dom.name + '][value=' + v + ']', true);
65 Ext.getCmp(radio.id).setValue(true);
68 if(this.rendered && this.checked){
69 checkEl = checkEl || this.getCheckEl();
70 els = this.getCheckEl().select('input[name=' + this.el.dom.name + ']');
71 els.each(function(el){
72 if(el.dom.id != this.id){
73 Ext.getCmp(el.dom.id).setValue(false);
81 getCheckEl: function(){
83 return this.el.up('.x-form-radio-group');
85 return this.el.up('form') || Ext.getBody();
88 Ext.reg('radio', Ext.form.Radio);