3 * Copyright(c) 2006-2009 Ext JS, LLC
5 * http://www.extjs.com/license
8 * @class Ext.form.RadioGroup
\r
9 * @extends Ext.form.CheckboxGroup
\r
10 * A grouping container for {@link Ext.form.Radio} controls.
\r
12 * Creates a new RadioGroup
\r
13 * @param {Object} config Configuration options
\r
16 Ext.form.RadioGroup = Ext.extend(Ext.form.CheckboxGroup, {
\r
18 * @cfg {Boolean} allowBlank True to allow every item in the group to be blank (defaults to true).
\r
19 * If allowBlank = false and no items are selected at validation time, {@link @blankText} will
\r
20 * be used as the error text.
\r
24 * @cfg {String} blankText Error text to display if the {@link #allowBlank} validation fails
\r
25 * (defaults to 'You must select one item in this group')
\r
27 blankText : 'You must select one item in this group',
\r
30 defaultType : 'radio',
\r
33 groupCls : 'x-form-radio-group',
\r
37 * Fires when the state of a child radio changes.
\r
38 * @param {Ext.form.RadioGroup} this
\r
39 * @param {Ext.form.Radio} checked The checked radio
\r
43 * Gets the selected {@link Ext.form.Radio} in the group, if it exists.
\r
44 * @return {Ext.form.Radio} The selected radio.
\r
46 getValue : function(){
\r
48 this.eachItem(function(item){
\r
58 * Sets the checked radio in the group.
\r
59 * @param {String/Ext.form.Radio} id The radio to check.
\r
60 * @param {Boolean} value The value to set the radio.
\r
61 * @return {Ext.form.RadioGroup} this
\r
63 onSetValue : function(id, value){
\r
64 if(arguments.length > 1){
\r
65 var f = this.getBox(id);
\r
69 this.eachItem(function(item){
\r
71 item.setValue(false);
\r
77 this.setValueForItem(id);
\r
81 setValueForItem : function(val){
\r
82 val = String(val).split(',')[0];
\r
83 this.eachItem(function(item){
\r
84 item.setValue(val == item.inputValue);
\r
89 fireChecked : function(){
\r
90 if(!this.checkTask){
\r
91 this.checkTask = new Ext.util.DelayedTask(this.bufferChecked, this);
\r
93 this.checkTask.delay(10);
\r
97 bufferChecked : function(){
\r
99 this.eachItem(function(item){
\r
105 this.fireEvent('change', this, out);
\r
108 onDestroy : function(){
\r
109 if(this.checkTask){
\r
110 this.checkTask.cancel();
\r
111 this.checkTask = null;
\r
113 Ext.form.RadioGroup.superclass.onDestroy.call(this);
\r
118 Ext.reg('radiogroup', Ext.form.RadioGroup);
\r