//new 一个RadioGroup组件
var radiogroup= new Ext.form.RadioGroup
(
{ fieldLabel : "性别",
items : [
{ boxLabel : '团早唯男', inputValue : '1', checked : true, name : "radSex" },
{ boxLabel : '女, name : "radSex", inputValue : '2' }
]
}
);
然后还需要重写radiogroup的两个方法,在按照我上面这样做就塌培可以了//RadioGroup重写的getValue和setValue
Ext.override(Ext.form.RadioGroup, { getValue: function(){ var v; if (this.rendered) { this.items.each(function(item){ if (!item.getValue()) return true; v = item.getRawValue(); return false; }); } else { for (var k in this.items) { if (this.items[k].checked) { v = this.items[k].inputValue; break; } } } return v; }, setValue: function(v){ if (this.rendered) this.items.each(function(item){ item.setValue(item.getRawValue() == v); }); else { for (var k in this.items) { this.items[k].checked = this.items[k].inputValue == v; } } } });
//获取的是inputValue的值
radiogroup.getValue();
//设置睁昌值选中
radiogroup.setValue(“1”);