使用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()方法。立即就会得到值。

  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) {

}

});

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-09-15
  • 2021-07-10
  • 2022-12-23
  • 2022-01-16
  • 2021-12-10
  • 2021-05-18
猜你喜欢
  • 2021-11-21
  • 2021-06-23
  • 2021-10-30
  • 2022-12-23
  • 2021-12-29
  • 2021-12-08
  • 2022-02-09
相关资源
相似解决方案