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