1
在一个组件(例如制表符)中,两个网格同时加载数据,我使用下面的函数创建一个全局掩码,只有当所有的存储都被加载时才会被删除。它通常运作良好。Ext.each递减循环错误计数
testLoadAllStores: function(allStores, component){
var indexStores = 0;
setTimeout(function() {
Ext.each(allStores, function(storeId) {
var store = Ext.getStore(storeId);
if(store){
if(store.isLoading()){
indexStores++
console.log(indexStores);
store.on('load', function() {
indexStores--;
console.log(indexStores);
if (indexStores == 0){
setTimeout(function() {
if(component.isMasked()){
component.unmask();
}
}, 500);
}
});
}
else if(!store.isLoading() && indexStores == 0){
setTimeout(function() {
if(component.isMasked()){
component.unmask();
}
}, 500);
}
}
});
}, 500);
}
在控制器中的函数被调用但是我有下面的情况如下问题
var allStores = ['storeOne', 'storeTwo'];
var component = Ext.getBody();
component.mask();
App.util.Util.testLoadAllStores(allStores, component);
:每格的行选择时将显示两个图表的时间。在这种情况下,函数testLoadAllStores被调用,并且只有当图表商店被加载时,解除屏蔽被激发。
问题是,我每次选择一行(selectChange事件)时indexStores--给出以下值(它的工作原理,但倒计时不正确)。
//first selection
1
2
1
0
//second selection
1
2
-1
1
-2
0
// third selection
1
2
-3
-1
1
-4
-2
0