日期:2014-05-16  浏览次数:20370 次

EXTJS4 郁闷的Loading

使用EXTJS4,写联动的combo控件,首次选择联动效果,可以正常显示和选择。

?


?

再次切换选择‘一级编码’,动态加载‘二级编码’数据可以正常加载,但是始终出现一个loading的遮盖层,选择不了下拉数据,奇怪的问题,寻求解决方案:

?


?

代码格式基本如下:

?

1、存储first_store,‘一级编码’的数据源,设置为autoLoad : true

?

?

var first_store = Ext.create('Ext.data.Store', {
			model : 'eht.model.ColVal',
			proxy : {
				type : 'ajax',
				url : '../myconfig/Config_viewConfigForCV.go?command=all.first&n='+new Date().getTime(),
				fields : ['col_id', 'col_name'],
				reader : {
					type : 'json',
					root : 'data'
				}
			},
			autoLoad : true,
			remoteSort:true
		});

?2、combo的‘一级编码’,在select中处理‘二级编码’的查询设置。

?

 {
		       	                xtype : 'combo',
		       	                fieldLabel : '一级编码',
		       	                blankText : "此项不能为空",
								emptyText : '此项不能为空',
								allowBlank : false,
								margin : '0 5 0 0',
								id : 'first_id',
								name : 'first_id',
								hiddenName : 'first_id',
								displayField : "col_name",
								valueField : "col_id",
								triggerAction: 'all',
								queryMode: 'local',
								store : first_store,
								listeners : {
										select : function(combo, record, index) {
											Ext.getCmp('second_id').clearValue();
											Ext.getCmp('second_id').store.load({params:{first_id:combo.value}});
											
										}
								}
							}

?3、cmbo的‘二级编码’设置

?

xtype : 'combo',
		        	          editable : false,
							  allowBlank : false,
							  margin : '0 5 0 0',
							  fieldLabel : '二级编码',
							  id:'second_id',
							  name:'second_id',
							  hiddenName:'second_id',
							  emptyText : '请选择...',
							  displayField : 'col_name',
							  valueField : 'col_id',
							  queryMode: 'local',
							  triggerAction: 'all',
							  typeAhead: true,
							  store : 
							  	{
							        extend: 'Ext.data.Store',
									model : 'eht.model.ColVal',
									proxy : {
										type : 'ajax',
										url : '../myconfig/Config_viewConfigForCV.go?command=all.second&n='+new Date().getTime(),
										fields : ['col_id', 'col_name'],
										reader : {
											type : 'json',
											root : 'data'
										}
									},
									autoLoad : false,
									remote : true,
									remoteSort:true,
									listeners : {
										load: function(store){
										    Ext.getCmp('second_id').setValue(store.getAt(0).get('col_id')) 
										} 
									}
							  },
							  lastQuery: ''
				            }

?4、不知道哪里的问题,可以看见数据都可以正常加载,就是在选择那个‘二级编码’后,切换‘一级编码’,再次选择‘二级编码’,就出现一个loading的遮盖层,选择不了数据,但是数据可以看见已经正常加载了????

1 楼 jumboluo 2012-03-30  
也遇到同样的问题,也不知道怎么解决啊。
2 楼 jumboluo 2012-03-30  
这是一个Ext的一个bug:
http://www.sencha.com/forum/showthread.php?153490-Combo-Box-Store-Loading

解决方法:
store.on('load', function (store, records, successful, options) {
    if (successful && Ext.typeOf(combo.getPicker().loadMask) !== "boolean") {
        combo.getPicker().loadMask.hide();
    }
});
3 楼 55558888 2012-08-09  
将 queryMode: 'local', 改为  queryMode: 'remote'