PDA

View Full Version : PagingToolbar in gridPanel getStore()



trasherdk
16 May 2011, 2:32 AM
Having a PagingToolbar on a gridPanel present me with following challenge.

When running, FireBug console, this sequence of commands:


gp = Ext.getCmp('customer-grid-panel');
gs = gp.getStore();
gs.load({params: { start: 0, count: 10 }});

All seems good. The load fires, and data is returned from server.

In my mind, the following piece of code should be more or less the same, right?


,bbar: new Ext.PagingToolbar({
pageSize: 10
,store: Ext.getCmp('customer-grid-panel').getStore()
,displayInfo: true
,displayMsg: 'Displaying topics {0} - {1} of {2}'
,emptyMsg: "No topics to display"
,items:['-']
})


But results in Ext.getCmp('customer-grid-panel') is undefined

Am i missing the point totally ?

trasherdk
18 May 2011, 1:39 AM
Ok, i found the problem, and solution.

Problem was, in short: The store does not exist at the time the bbar is initialized.

Solution, in short: Declare a storeId on the grid's store. I had an 'id'.
(changing from red to green)



,store: new Ext.data.JsonStore({
id: 'customer-grid-store'
storeId: 'customer-grid-store'
,autoLoad: true
,autoDestroy: true


And then on the bbar, i changed:


,bbar: new Ext.PagingToolbar({
pageSize: 10
,store: Ext.getCmp('customer-grid-panel').getStore()
,store: 'customer-grid-store'
,displayInfo: true
,displayMsg: 'Displaying topics {0} - {1} of {2}'
,emptyMsg: "No topics to display"
,items:['-']
})


And now all is good. Moving on :)

shuixiya1999
18 May 2011, 5:33 PM
This is an error that "Problem was, in short: The store does not exist at the time the bbar is initialized."

the store totally exists, but the grid hasn't rendered to the document dom.

trasherdk
18 May 2011, 8:12 PM
Well, you are right. The store did not exist in the context i tried to reach it.

Otherwise, the Ext.getCmp('customer-grid-panel').getStore() should have worked :D