Extjs radiogroup 获取选中

获取 extjs radiogroup 选中值 extjs 4

 {
xtype: 'radiogroup',
name: 'c',
id: 'selectThePathforBackup2',
fieldLabel: '选择路径',
columnWidth: 0.7,
margin: '10 5 5 5',
layout: {
type: 'vbox' //指定为hbox布局 元素水平排列,一个挨一个
//align: 'stretch'  //指定元素的高将充满容器的垂直空间
},
items: [
        {
boxLabel: 'C',
name: 'c',
margin: '0 0 0 0',
inputValue: '/a/b',
checked: true
},
{
boxLabel: 'D',
name: 'c',
margin: '0 0 0 0',
inputValue: '/c/d'
},
{
boxLabel: 'C',
name: 'c',
margin: '0 0 0 0',
inputValue: '/a/b',
checked: true
},
{
boxLabel: 'D',
name: 'c',
margin: '0 0 0 0',
inputValue: '/c/d'
},

//------------------------------
var jobRadio = Ext.getCmp('selectThePathforBackup2');
var selectPathRoute =jobRadio.getValue().c;//c 为name属性名

注:
百度到以下方法并不适用 可能版本原因
解决表单加载初始值,自动选中单选按钮组的问题,今早才查到资料,原来ext3.1已经修正了这个问题,但是需要的是给组和里面的单选按钮都要设置同样的name属性,我就是没有设定group的name,就悲剧了,这样设置即可:


Js代码
{
xtype: 'radiogroup',
fieldLabel: 'Auto Layout',
name: 'rb-auto',
id:'atype',
items: [
{boxLabel: 'Item 1', name: 'rb-auto', inputValue: 1},
{boxLabel: 'Item 2', name: 'rb-auto', inputValue: 2, checked: true},
{boxLabel: 'Item 3', name: 'rb-auto', inputValue: 3},
{boxLabel: 'Item 4', name: 'rb-auto', inputValue: 4},
{boxLabel: 'Item 5', name: 'rb-auto', inputValue: 5}
]
获取单选按钮的值的代码: var atype = Ext.getCmp(‘atype’).getValue();
他的弹出值是[object Object],我查了JS基础,说是为空或者不是对象
我的需求是:我要知道用户选了单选还是多选的按钮,我需要得到值。
取值方法:

buttons:[{
text:'xx',
handler:function(){
var rg = Ext.getCmp('atype');
var r = rg.getValue();
//关键
var value = r.inputValue;
alert(value) ;
}
}]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值