ext store.load异步问题
使用ext的store.load(),之后然后使用store.getCount(),
store.load(parameter);
store.getCount();
发现其值始终为0,好像没有load成功,查了相关的资料发现,store.load其实是个异步方法,load之后的结果不能再load函数后马上显示。
如果需要改变这种方法,那么应该将store.getCount放在load的callback中。
例如:
store.load({callback : function(){
store.getCount();
}
});
这样的话每次调用load的时候就会去调store.getCount()方法。立即就会得到值。
store.load(parameter);
store.getCount();
发现其值始终为0,好像没有load成功,查了相关的资料发现,store.load其实是个异步方法,load之后的结果不能再load函数后马上显示。
如果需要改变这种方法,那么应该将store.getCount放在load的callback中。
例如:
store.load({callback : function(){
store.getCount();
}
});
这样的话每次调用load的时候就会去调store.getCount()方法。立即就会得到值。
this.userStore.removeAll();
    userStore.load({
      callback : function(r, options, success) {
       alert("callback");
       if (success) {
        for (var i = 0; i < r.length; i++) {
         var record = r[i];
         var v = record.data.userName;
         alert(v);
        }
       }
      }
     });
Ext.Ajax.request({
url: '',
method: 'post',
async: false, //同步请求
success: function(response) {
}
});
 
                    
                     
                    
                 
                    
                 
                
            
         
         浙公网安备 33010602011771号
浙公网安备 33010602011771号