var radiogroup= new Ext.form.RadioGroup({
fieldLabel : "性别",
items : [{
boxLabel : '男',
inputValue : '1',
checked : true,
name : "radSex"
}, {
boxLabel : '女,
name : "radSex",
inputValue : '2'
}]
});
radiogroup.getValue()获取的是inputValue的值
radiogroup.setValue(“1”);//设置值选中
然后还需要重写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;
}
}
}
});