View Full Version : How to get correct count of the Grids store?

7 Dec 2011, 5:15 AM
Hi There,

I am able to get the store in the Grids dockItem. Here is the code
This dockedItems is to Gird.panel

dockedItems: [{
xtype: 'toolbar',

items :[
xtype: 'tbtext',
text : 'No Records to Display',
scope : this,
afterrender: function()
{ var me = this;
store = Ext.data.StoreManager.lookup('myStore');
alert(store )
var count = store.getCount();
var text = ""
dock: 'bottom'


my store is

var store2 = Ext.create('Ext.data.Store', {
pageSize: 5,
storeId: 'myStore',
model: 'ForumThread2',

But the store is not showing correct records from store.

Please guide me. I want to know what is wrong here? I want correct count in the "count" variable.

7 Dec 2011, 5:25 AM
store load is an asynchronous process....

7 Dec 2011, 5:39 AM
So do you mean that, we can not get the exact count to the toolbar ?

Please suggest , what can be done if this is not possible.

7 Dec 2011, 5:59 AM
I mean, do what ever you want with the store data only after data is loaded, in a callback:

scope :this,
callback:function(records, operation, success){
//the operation (http://docs.sencha.com/ext-js/4-0/#!/api/Ext.data.Operation) object contains all of the details of the load operation console.log(records);

consult http://docs.sencha.com/ext-js/4-0/#!/api/Ext.data.Store-method-load

7 Dec 2011, 6:39 AM
Thank you So much.. It is working now..

7 Dec 2011, 6:46 AM
I would suggest you to read about asynchronous and synchronous requests.
p.s don't forget to mark answered.