Extjs radioGroup 取选中的值 设置值选中

定义 radiogroup

var radiogroup= new Ext.form.RadioGroup({ 
fieldLabel : "性别",
items : [ 
          { boxLabel : '男', inputValue : '1', checked : true, name : "radSex" },
          { boxLabel : '女, name : "radSex", inputValue : '2' } 
       ]
});
重写getValue 和setValue
Ext.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 获取


你可能感兴趣的:(Extjs radioGroup 取选中的值 设置值选中)