略表Extjs data.Store 有时不能使用的原因

今天早上,想在自定义组件中展示数据的个数,用了n久,data.Store 的getCount方法,总是返回为0,但是用console.log()该store,却有数据,如此让人抓狂!后来终于明白了,因为在在自定义组件构造函数中,此时

store并没有加载完,故无法此时操作store,而console.log()方法执行于渲染之后,原来是执行周期搞了鬼!才导致被欺骗,真是浪费时间。

不过我们可以这样操作store:

    me.store.load({
            callback:function(records,opeartion,success){
                if(success){
                    me.buttombar.getComponent("lblInfo").setText("共 "+me.store.getCount()+" 项");
                }
            }
        })

通过调用store的load方法,在回调函数中做出自己想要的改变,对此只想说一句,造孽啊!