Extjs 4.1 - 如何等待所有存储在组合中被加载 [英] Extjs 4.1 - How to wait all store in combo is loaded
本文介绍了Extjs 4.1 - 如何等待所有存储在组合中被加载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
var arrCombos = window.query('二合一');
Ext.each(arrCombos,function(combo){
combo.getStore()。load(); //加载
});
WaitForFunction(arrCombos); //等待加载完成
window.show(); //显示我的窗口
这是我的 WaitForFunction
function WaitForFunction(arrCombos){
var all = 1;
Ext.each(arrCombos,function(combo){
if(combo.store.isLoading()){
all = 0;
}
});
if(all == 0){
setTimeout(WaitForFunction(arrCombos),100);
}
}
但是失败了,说太多的递归
我该怎么做,谢谢。
解决方案
这样做应该可以工作:
var arrCombos = window.query('combo'),
storeCt = 0;
function checkState(){
if( - storeCt == 0)
window.show();
}
Ext.each(arrCombos,function(combo)){
var store = combo.getStore();
storeCt ++;
store.on ('load',checkState,this,{single:true})
store.load(); //加载
});
I have a window include many combo with default autoload = false. I want to wait all combo in my window is loaded after that i will show window like
var arrCombos = window.query('combo');
Ext.each(arrCombos, function(combo){
combo.getStore().load(); // load
});
WaitForFunction(arrCombos); // wait for loading done
window.show(); // show my window
Here is my WaitForFunction
function WaitForFunction(arrCombos) {
var all = 1;
Ext.each(arrCombos, function(combo){
if (combo.store.isLoading()) {
all = 0;
}
});
if (all == 0){
setTimeout(WaitForFunction(arrCombos), 100);
}
}
But fail, that said too much recursion
How can i do that thank.
解决方案
Quick and dirty but something like this should work:
var arrCombos = window.query('combo'),
storeCt = 0;
function checkState() {
if(--storeCt == 0)
window.show();
}
Ext.each(arrCombos, function (combo) {
var store = combo.getStore();
storeCt++;
store.on('load', checkState, this, {single: true})
store.load(); // load
});
这篇关于Extjs 4.1 - 如何等待所有存储在组合中被加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文