Extjs2.2 RadioGroup的声明对象和getValue、SetValue方法的用法
2012-11-01 15:22
417 查看
用过的朋友都知道extjs的RadioGroup组件的setValue和SetValue貌似有bug。是不成功的
在此我来解决一下这个问题:
1、声明RadioGroup的代码:
[code]
在此我来解决一下这个问题:
1、声明RadioGroup的代码:
var radiogroup= new Ext.form.RadioGroup({ fieldLabel : "性别", items : [{ boxLabel : '男', inputValue : '1', checked : true, name : "radSex" }, { boxLabel : '女, name : "radSex", inputValue : '2' }] });2、重写SetValue和GetValue两个方法从而得到可用的方法
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; } } } });3、调用方法完成设置:
[code]
radiogroup.getValue() //获取的是inputValue的值 radiogroup.setValue(“1”);//设置值选中
相关文章推荐
- extjs的radiogroup单选按钮获取选中值的方法
- ExtJS表单组件RadioGroup属性用法(选中初始值、表单加载,选中取值)的要点
- EXTJS 2.2版本在IE9中会报错:对象不支持“createContextualFragment”属性或方法
- EXTJS 4.2 资料 控件之radiogroup 的用法
- 获取表单对象,得三种方法getElementById(), getElementsByName(), and getElementsByTagName() 和用法
- SQL技术内幕-3---类似临时表用法的变量声明方法
- Objective-c学习日总结之与C的区别及类与对象的定义,类的声明及调用方法
- extjs radiogroup 互斥
- extjs radioGroup怎么取选中的值?怎么设置值选中?
- 无废话ExtJs 入门教程十[单选组:RadioGroup、复选组:CheckBoxGroup]
- HttpServletRequest对象方法的用法
- 安卓开发listview中包含radiogroup选项在滚动时自动选中的解决方法。BaseAdapter,RadioGroup,ListView,ViewHolder
- 单选框 RadioGroup 和 RadioButton 的用法
- 面向对象-异常概述、try catch方法、异常声明throws、多异常处理
- ExtJs--09--javascript对象的方法的3种写法 prototype通过原型设置方法效率最好
- HttpServletRequest对象方法的用法小结
- android RadioGroup和RadioButton的用法
- Android开发笔记:基础控件之RadioGroup用法
- Python 正则表达式的 Match 对象的 group 方法
- ExtJS 获取radioGroup及CheckboxGroup值