zoukankan      html  css  js  c++  java
  • Extjs RadioGroup中Radio的切换

    现在用Ext+Struts2开发项目,遇到了一个问题,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,
    		290,
    		height:160,
    		layout:'form',
    		buttonAlign:'center',
    		labelAlign:'center',
    		defaults:{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('');
    				}
    			}
    		]
    	});
    });
    

    显示效果如下所示:

  • 相关阅读:
    ASP.NET 设计模式 读书摘记1
    [Exception]Sys.WebForm.PageRequestManagerServerErrorException:500
    [Exception] 当前 TransactionScope 已完成
    [Javascript]客户端检测
    c.Tom and paper
    Currency System in Geraldion (Codeforces 560A)
    巡逻机器人(BFS)
    比赛建金字塔问题解题报告
    除法(暴力)
    比赛找丢失的数解题报告T
  • 原文地址:https://www.cnblogs.com/sunzhenxing19860608/p/1818314.html
Copyright © 2011-2022 走看看