ExtJs中getValue和getRawValue及combo的事件


{
					id :'editSendStatus',
					xtype : 'combo',
					fieldLabel : '发送状态',
					displayField: 'name',
					mode:'local',
					valueField: 'key',
					allowBlank : false,
					editable :false,
					<strong>store: Ext.create('Ext.data.Store', {
						fields: ['key', 'name'],
						data : [
								{key:"0", name:"不发送"},
								{key:"1", name:"发送"}
								]
					}),
					<span style="color:#cc0000;">listeners:</span></strong>{ 
//						afterRender:function(combo){ 
// 							//设置下拉列表值
//							<strong>combo.setValue(selectData[0].get("stamp_status"));</strong>//同时下拉框会将与name为firstValue值对应的text显示 
//						} ,
						<strong>select:function(combo){
							if(combo.getRawValue()=="发送"){
								parent.parent.Ext.getCmp('check_send_status').setDisabled(false);
							}
							if(combo.getRawValue()=="不发送"){
								parent.parent.Ext.getCmp('check_send_status').setDisabled(true);
							}

						}</strong>
						
					}
				},{
					id :'check_send_status',
					xtype : 'combo',
					fieldLabel : '签章检查',
					displayField: 'name',
					mode:'local',
					valueField: 'key',
					disabled :'true',
					allowBlank : false,
					editable :false,
					store: Ext.create('Ext.data.Store', {
						fields: ['namekey', 'name'],
						data : [
								{key:"0", name:"否"},
								{key:"1", name:"是"}
								]
					})
					,
					listeners:{ 
						afterRender:function(combo){ 
							//设置下拉列表值
							//Ext.getCmp('check_send_status').getRawValue()
							combo.setValue(selectData[0].get("check_send_status"));//同时下拉框会将与name为firstValue值对应的text显示 
						} 
					}
				}]
	});
这段代码非常经典:

   需要掌握的东西:1)combo怎么创建

                                  2)对于这两个combo,第一个下拉列表默认的是不发送的,第二个下拉列表是不可编辑的,我们在第一个combo设置了listener事件,里面还有个select事件,当select事件会触发是否让第二个combo可编辑.第二个combo中有个afterRender是渲染事件

                                  3)设置默认的的combo的值:combo.setValue(selectData[0].get("check_send_status"));

                                 4)在一个combo中获得另外一个combo的内容,或者相关属性:parent.parent.Ext.getCmp('check_send_status').setDisabled(false);


关于更多的理解参考:http://blog.csdn.net/itjavawfc/article/details/41129957



下面看看一个从数据库中加载数据到前台的combox中去:

实现的效果:服务器名称为combox

   


		  var <strong>Service_store</strong>=  Ext.create('Ext.data.Store', {
				 fields : ['group_id', 'group_name'],
				  proxy: {        
						type: 'ajax',       
						url : '/realware/common/queryConfig.action?para='+(this.para+"_service"),
						reader: {  
							root : 'data',
							type: 'json'
						}
				}
			});
			 
			Service_store.load({
				method : 'post',
				params : {
					field : "group_id,group_name"
				}
			}); 

			// Create the combo box, attached to the states data store
			var signcombo_service=Ext.create('Ext.form.ComboBox', {
			    id:'sign_service_id',
			    fieldLabel: '服务名称',
			    store:<strong> Service_store</strong>,
			    disabled:true,
			    emptyText:name_test,                          //'签名服务选项',
			    queryMode: 'remote',
			    displayField: 'group_name',
			    valueField: 'group_id',
			    labelAlign:'left',
 			    labelWidth:220,
			    width:600
			    
			});
		 
			var sign_label=Ext.create("Ext.form.Label",{
            		labelWidth:200,
            		width:600,
            		style:'color:blue',
            		text:"请选择需要配置的服务"  
            	});
			 this.groupPanel.add([signcombo_service]);
	         this.groupPanel.add([sign_label]);
            		
      } 


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值