定义 radiogroup
var radiogroup= new Ext.form.RadioGroup({
fieldLabel : "性别",
items : [
{ boxLabel : '男', inputValue : '1', checked : true, name : "radSex" },
{ boxLabel : '女, name : "radSex", inputValue : '2' }
]
});重写getValue 和setValueExt.override(Ext.form.RadioGroup, {
getValue: function() {
var v;
this.items.each(function(item) {
if ( item.getValue() ) {
v = item.getRawValue();
return false;
}
});
return v;
},
setValue: function(v) {
if(this.rendered)
this.items.each(function(item) {
item.setValue(item.getRawValue() == v);
});
else
for(k in this.items) this.items[k].checked = this.items[k].inputValue == v;
}
}); 获取radiogroup值还可以 radiogroup.getValue().type 获取
本文介绍了如何在Ext.js中自定义RadioGroup组件,并通过重写getValue和setValue方法来获取和设置组件值,提供了一个灵活的解决方案。
1772

被折叠的 条评论
为什么被折叠?



