ExtJS 获取单选按钮的值 radiogroup 获取值 fieldset(radio) 获取值
2013-06-19 12:44
393 查看
ExtJS 获取单选按钮的值 radiogroup 获取值
fieldset(radio) 获取值
1 { 2 xtype: 'fieldset', 3 id: 'job', 4 title: '职业', 5 autoHeight: true, 6 defaultType: 'radio', //设置fieldset内的默认元素为radio 7 //hideLabel: false, 8 layout: 'hbox', 9 defaults: { 10 flex: 1 11 }, 12 items: [ 13 { boxLabel: '学生', name: 'job', inputValue: '1', checked: true }, 14 { boxLabel: '教师', name: 'job', inputValue: '2' }, 15 { boxLabel: '其他', name: 'job', inputValue: '3' } 16 ] 17 }
如果是以上定义,则页面效果为:
![](http://pic002.cnblogs.com/images/2012/319502/2012081613424532.jpg)
通过以下语句中变量 job 保存的是选中的标签值(学生、教师、其他)
1 var jobRadio = Ext.getCmp('job').items; 2 var jobValue = loginForm.getForm().findField("job").getGroupValue(); //此处获取到的是inputValue的值 3 var job; 4 for(var i = 0; i < jobRadio.length; i++){ 5 if(jobRadio.get(i).inputValue == jobValue){ 6 job = jobRadio.get(i).boxLabel; 7 break; 8 } 9 } 10 Ext.MessageBox.alert('提示', '您的职业是' + job);
以上是通过 fieldset 定义的 radio 组件获取值的方法。下面是 radiogroup 组件获取值的方法
1 { 2 //xtype : 'fieldcontainer', 3 xtype: 'radiogroup', 4 id: 'sex', 5 fieldLabel : 'Sex', 6 hideLabels: false, 7 defaults: { 8 flex: 1 9 }, 10 layout: 'hbox', 11 items: [ 12 { 13 boxLabel : 'Male', 14 name : 'sex', 15 inputValue: 'male' 16 }, { 17 boxLabel : 'Female', 18 name : 'sex', 19 inputValue: 'female' 20 } 21 ] 22 }
页面效果为:
![](http://pic002.cnblogs.com/images/2012/319502/2012081613564020.jpg)
获取值的代码如下:
1 var sex = Ext.getCmp('sex').getChecked()[0].boxLabel; 2 Ext.MessageBox.alert('提示', '您的性别是' + sex);
相关文章推荐
- ExtJS 获取单选按钮的值 radiogroup 获取值 fieldset(radio) 获取值
- extjs的radiogroup单选按钮获取选中值的方法
- ExtJS 获取单选按钮的值 radiogroup 获取值 fieldset(radio) 获取值
- ExtJS 单选按钮组RadioGroup在IE浏览器中显示不出来的问题
- 单选按钮RadioGroup和RadioButton
- jQuery如何获取选中单选按钮radio的值
- ExtJS 获取复选框的值 checkboxgroup 获取值 fieldset(checkbox) 获取值
- android基本控件示例RadioButton单选按钮,一般和RadioGroup一起用(03)
- 设置单选按钮RadioGroup
- 使用jQuery获取单选按钮radio的选中值
- jQuery获取单选按钮radio选中值与去除所有radio选中状态的方法
- 3.Android之单选按钮RadioGroup和复选框Checkbox学习
- jQuery获取循环中的选中单选按钮radio的值
- 单选按钮RadioButton&RadioGroup
- 单选框RadioGroup,单选按钮RadioButton的使用
- js获取下拉列表选中项的值和文本(select)以及获取单选按钮(radio)组的值和修改选中项
- 无废话ExtJs 入门教程十[单选组:RadioGroup、复选组:CheckBoxGroup]
- jQuery获取单选按钮(Radio)当前选中项的值
- RADIO按钮GROUP属性未设置正确的TAB顺序而引起单选BUG
- 使用jquery获取单选按钮radio的值