Extjs RadioGroup中Radio的切换
Ext.onReady(function(){
Ext.QuickTips.init();
var adminRadio=new Ext.form.Radio({
boxLabel:'管理员',
inputValue:'admin',
listeners:{
'check':function(){
//alert(adminRadio.getValue());
if(adminRadio.getValue()){
userRadio.setValue(false);
adminRadio.setValue(true);
}
}
}
});
var userRadio=new Ext.form.Radio({
boxLabel:'普通用户',
inputValue:'user',
listeners:{
'check':function(){
if(userRadio.getValue()){
adminRadio.setValue(false);
userRadio.setValue(true);
}
}
}
});
var _form=new Ext.form.FormPanel({
renderTo:'login-form',
title:'系统登录',
frame:true,
width:290,
height:160,
layout:'form',
buttonAlign:'center',
labelAlign:'center',
defaults:{width:160,labelWidth:80,xtype:'textfield'},
items:[
{fieldLabel:'用 户 名',vtype:'alpha',id:'name',name:'name'},
{fieldLabel:'通 行 证',inputType:'password',vtype:'alpha',id:'pass',name:'pass'},
{
xtype:'radiogroup',
fieldLabel:'用户类型',
id:'typeRadio',
items:[
adminRadio,userRadio
]
}
],
buttons:[
{text:'登 录',style:'margin-right:15'},
{
text:'清 除',
style:'margin-left:15',
handler:function(){
var _name=_form.findById('name').setValue('');
var _pass=_form.findById('pass').setValue('');
}
}
]
});
});
Ext.QuickTips.init();
var adminRadio=new Ext.form.Radio({
boxLabel:'管理员',
inputValue:'admin',
listeners:{
'check':function(){
//alert(adminRadio.getValue());
if(adminRadio.getValue()){
userRadio.setValue(false);
adminRadio.setValue(true);
}
}
}
});
var userRadio=new Ext.form.Radio({
boxLabel:'普通用户',
inputValue:'user',
listeners:{
'check':function(){
if(userRadio.getValue()){
adminRadio.setValue(false);
userRadio.setValue(true);
}
}
}
});
var _form=new Ext.form.FormPanel({
renderTo:'login-form',
title:'系统登录',
frame:true,
width:290,
height:160,
layout:'form',
buttonAlign:'center',
labelAlign:'center',
defaults:{width:160,labelWidth:80,xtype:'textfield'},
items:[
{fieldLabel:'用 户 名',vtype:'alpha',id:'name',name:'name'},
{fieldLabel:'通 行 证',inputType:'password',vtype:'alpha',id:'pass',name:'pass'},
{
xtype:'radiogroup',
fieldLabel:'用户类型',
id:'typeRadio',
items:[
adminRadio,userRadio
]
}
],
buttons:[
{text:'登 录',style:'margin-right:15'},
{
text:'清 除',
style:'margin-left:15',
handler:function(){
var _name=_form.findById('name').setValue('');
var _pass=_form.findById('pass').setValue('');
}
}
]
});
});