extjs radioGroup怎么取选中的值?怎么设置值选中
2个回答
展开全部
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Extjs 4.2 demo</title>
<link rel="stylesheet" href="../resources/css/ext-all.css">
<script src="../bootstrap.js"></script>
<script>
Ext.onReady(function(){
Ext.create('Ext.Panel',{
width:450,
items:[{
width:'100%',
xtype: 'radiogroup',
items: [
{boxLabel: 'Item 1', name: 'rb-x'},
{boxLabel: 'Item 2', name: 'rb-x'},
//checked属性 设置默认选中
{boxLabel: 'Item 3', name: 'rb-x',checked: true},
{boxLabel: 'Item 4', name: 'rb-x'}
]
},{
xtype:'button',
text:'获取选择的值'悉冲,
handler:function(){
var rg = this.up('panel').items.items[0];
var selected 空告= rg 睁亏歼&& rg.getChecked();
selected = selected && selected[0];
selected && Ext.Msg.alert('选择的值',selected && selected.boxLabel);
}
},{
xtype:'button',
text:'选中第2个',
handler:function(){
var rg = this.up('panel').items.items[0];
var box2 = rg && rg.getBoxes()[1];
box2 && box2.setValue(true);
}
}],
renderTo:Ext.getBody()
});
});
</script>
</head>
<body>
</body>
</html>
展开全部
<!doctype html><培洞html lang="en"><head> <meta charset="UTF-8"> <title>Extjs 4.2 demo</title> <link rel="stylesheet" href="../resources/css/ext-all.css"> <script src="../bootstrap.js"></script> <script> Ext.onReady(function(){ Ext.create('Ext.Panel',{ width:450, items:[{ width:'100%', xtype: 'radiogroup', items: [ {boxLabel: 'Item 1', name: 'rb-x'}, {boxLabel: 'Item 2', name: 'rb-x'}, //checked属性 设置默认选中 {boxLabel: 'Item 3', name: 'rb-x',checked: true}, {boxLabel: 'Item 4', name: 'rb-x'} ] },{ xtype:'button', text:'获取选择的值', handler:function(){ var rg = this.up('panel').items.items[0]; var selected = rg && rg.getChecked(); selected = selected && selected[0]; selected && Ext.Msg.alert('选择的值',selected && selected.boxLabel); } },{ xtype:'button', text:'选中第2个困昌', handler:function(){ var rg = this.up('panel').items.items[0]; var box2 = rg && rg.getBoxes()[1]; box2 && box2.setValue(true); } }], renderTo:Ext.getBody() }); }); </script>配尺枯</head><body> </body></html>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询