Extjs 4.1 - How to wait all store in combo is loaded

泄露秘密 提交于 2019-12-10 22:41:27

问题


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.


回答1:


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
});


来源:https://stackoverflow.com/questions/17942315/extjs-4-1-how-to-wait-all-store-in-combo-is-loaded

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!