How to get data from extjs 4 store

前端 未结 2 1885
旧时难觅i
旧时难觅i 2021-01-06 06:53

Im stack with ext js 4 at the very beginning. Im trying to get the current user data when starting the application using store. But Im not getting any data from the store, e

2条回答
  •  渐次进展
    2021-01-06 07:32

    The problem itself isn't that the store does not contain data, the problem is that the store load is asyncronous therefore when you count the store records, the store is actualy empty. To 'fix' this, use the callback method of the store load.

    currentUser.load({
        scope   : this,
        callback: function(records, operation, success) {
            //here the store has been loaded so you can use what functions you like
            currentUser.count();
        }
    });
    

提交回复
热议问题