您的位置:首页 > Web前端 > JavaScript

Extjs radiogroup 获取选中

2015-08-06 13:21 633 查看
获取 extjs radiogroup 选中值 extjs 4

[code] {
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基础,说是为空或者不是对象

我的需求是:我要知道用户选了单选还是多选的按钮,我需要得到值。

取值方法:

[code]buttons:[{
text:'xx',
handler:function(){
var rg = Ext.getCmp('atype');
var r = rg.getValue();
//关键
var value = r.inputValue;
alert(value) ;
}
}]
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: