使用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的遮盖层,选择不了数据,但是数据可以看见已经正常加载了????

本文探讨了使用EXTJS4实现联动combo控件的开发过程,包括数据源配置、组合框属性设置及事件监听。重点解决了首次加载后的第二次切换导致的loading遮盖层问题,提供了代码示例和解决方案。
2万+

被折叠的 条评论
为什么被折叠?



