3 <title>The source code</title>
4 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
5 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
7 <body onload="prettyPrint();">
8 <pre class="prettyprint lang-js">/*!
10 * Copyright(c) 2006-2009 Ext JS, LLC
12 * http://www.extjs.com/license
14 <div id="cls-Ext.form.RadioGroup"></div>/**
\r
15 * @class Ext.form.RadioGroup
\r
16 * @extends Ext.form.CheckboxGroup
\r
17 * A grouping container for {@link Ext.form.Radio} controls.
\r
19 * Creates a new RadioGroup
\r
20 * @param {Object} config Configuration options
\r
23 Ext.form.RadioGroup = Ext.extend(Ext.form.CheckboxGroup, {
\r
24 <div id="cfg-Ext.form.RadioGroup-allowBlank"></div>/**
\r
25 * @cfg {Boolean} allowBlank True to allow every item in the group to be blank (defaults to true).
\r
26 * If allowBlank = false and no items are selected at validation time, {@link @blankText} will
\r
27 * be used as the error text.
\r
30 <div id="cfg-Ext.form.RadioGroup-blankText"></div>/**
\r
31 * @cfg {String} blankText Error text to display if the {@link #allowBlank} validation fails
\r
32 * (defaults to 'You must select one item in this group')
\r
34 blankText : 'You must select one item in this group',
\r
37 defaultType : 'radio',
\r
40 groupCls : 'x-form-radio-group',
\r
42 <div id="event-Ext.form.RadioGroup-change"></div>/**
\r
44 * Fires when the state of a child radio changes.
\r
45 * @param {Ext.form.RadioGroup} this
\r
46 * @param {Ext.form.Radio} checked The checked radio
\r
49 <div id="method-Ext.form.RadioGroup-getValue"></div>/**
\r
50 * Gets the selected {@link Ext.form.Radio} in the group, if it exists.
\r
51 * @return {Ext.form.Radio} The selected radio.
\r
53 getValue : function(){
\r
55 this.eachItem(function(item){
\r
64 <div id="method-Ext.form.RadioGroup-onSetValue"></div>/**
\r
65 * Sets the checked radio in the group.
\r
66 * @param {String/Ext.form.Radio} id The radio to check.
\r
67 * @param {Boolean} value The value to set the radio.
\r
68 * @return {Ext.form.RadioGroup} this
\r
70 onSetValue : function(id, value){
\r
71 if(arguments.length > 1){
\r
72 var f = this.getBox(id);
\r
76 this.eachItem(function(item){
\r
78 item.setValue(false);
\r
84 this.setValueForItem(id);
\r
88 setValueForItem : function(val){
\r
89 val = String(val).split(',')[0];
\r
90 this.eachItem(function(item){
\r
91 item.setValue(val == item.inputValue);
\r
96 fireChecked : function(){
\r
97 if(!this.checkTask){
\r
98 this.checkTask = new Ext.util.DelayedTask(this.bufferChecked, this);
\r
100 this.checkTask.delay(10);
\r
104 bufferChecked : function(){
\r
106 this.eachItem(function(item){
\r
112 this.fireEvent('change', this, out);
\r
115 onDestroy : function(){
\r
116 if(this.checkTask){
\r
117 this.checkTask.cancel();
\r
118 this.checkTask = null;
\r
120 Ext.form.RadioGroup.superclass.onDestroy.call(this);
\r
125 Ext.reg('radiogroup', Ext.form.RadioGroup);
\r