3 * Copyright(c) 2006-2010 Sencha Inc.
5 * http://www.sencha.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 {Array} items An Array of {@link Ext.form.Radio Radio}s or Radio config objects
19 * to arrange in the group.
22 * @cfg {Boolean} allowBlank True to allow every item in the group to be blank (defaults to true).
23 * If allowBlank = false and no items are selected at validation time, {@link @blankText} will
24 * be used as the error text.
28 * @cfg {String} blankText Error text to display if the {@link #allowBlank} validation fails
29 * (defaults to 'You must select one item in this group')
31 blankText : 'You must select one item in this group',
34 defaultType : 'radio',
37 groupCls : 'x-form-radio-group',
41 * Fires when the state of a child radio changes.
42 * @param {Ext.form.RadioGroup} this
43 * @param {Ext.form.Radio} checked The checked radio
47 * Gets the selected {@link Ext.form.Radio} in the group, if it exists.
48 * @return {Ext.form.Radio} The selected radio.
50 getValue : function(){
52 this.eachItem(function(item){
62 * Sets the checked radio in the group.
63 * @param {String/Ext.form.Radio} id The radio to check.
64 * @param {Boolean} value The value to set the radio.
65 * @return {Ext.form.RadioGroup} this
67 onSetValue : function(id, value){
68 if(arguments.length > 1){
69 var f = this.getBox(id);
73 this.eachItem(function(item){
81 this.setValueForItem(id);
85 setValueForItem : function(val){
86 val = String(val).split(',')[0];
87 this.eachItem(function(item){
88 item.setValue(val == item.inputValue);
93 fireChecked : function(){
95 this.checkTask = new Ext.util.DelayedTask(this.bufferChecked, this);
97 this.checkTask.delay(10);
101 bufferChecked : function(){
103 this.eachItem(function(item){
109 this.fireEvent('change', this, out);
112 onDestroy : function(){
114 this.checkTask.cancel();
115 this.checkTask = null;
117 Ext.form.RadioGroup.superclass.onDestroy.call(this);
122 Ext.reg('radiogroup', Ext.form.RadioGroup);