Extjs中为RadioGroup组件添加监听事件,来控制另一个组件是否显示

监听事件是change,针对整个组件来说的,下面是具体的实例:

		{
	   		xtype: 'panel',
	   		style: 'margin-left:50;',
	   		layout: 'column',
	   		autoWidth: true,
	   		items: [{
	   			layout: 'form',
	   			width: 240,
				items:[{
					xtype: 'radiogroup',
					width: 120,
					fieldLabel: '排      置',
					id: 'seqConfig',
					name: 'seqConfig1',
					items: [{
				    	boxLabel: '普通',
				    	itemId: 'general',
				    	name: 'seqConfig',
				    	inputValue: '普通',  //映射的值
				    	checked: true
				    },{
				    	boxLabel: '规律',
				    	id: 'regular',
				    	name: 'seqConfig',
				    	inputValue: '规律'
				    }],  
					listeners: {  
						"change": function() {  
							if (Ext.getCmp("seqConfig").getValue().inputValue == "规律") {  
								Ext.getCmp("ruleCheck").setVisible(true);  
							} else {  
								Ext.getCmp("ruleCheck").setVisible(false);  
							}  
						}  
					}
				}]
			}, {
	   			layout: 'form',
	   			xtype: 'panel',
	   			hidden: true,
	   			id: 'ruleCheck',
	   			style: 'margin-left:0;',
				items:[{
					store: new Ext.data.JsonStore({
						url: "./jxy/subsystem/queryUserRoleAction", 
				        autoLoad: true,
				        fields: ['id','roleName'],
				        root: 'data',
				        remoteSort: true,
						listeners: {
							load: function() {
								//window_add_user.findById("user.userRoleName").setValue(userroleStore.getAt(0).data.roleName);//给combobox赋默认值
							}
						}
					}),
					xtype: 'combo',
					fieldLabel: '请选择',
					width: 120,
					id: 'user.userRoleName',
					displayField: 'roleName',
					valueField: 'id',
					hiddenName: 'roleName',
					typeAhead: true,
					triggerAction: 'all',
					selectOnFocus: true,
					mod: 'remote',
					allowBlank: false,
					editable: false,
					emptyText: '--请选择--'
				}]
			}]
		}



 

你可能感兴趣的:(ExtJs)