PDA

View Full Version : store in dockedItems using named store



Greg_S
17 Apr 2012, 5:57 AM
Hi,

I am trying to add a pagingtoolbar and searchfield onto MVC app, broadly based on the Sencha example MVC.

I have a named store 'mystore' and have added dockedItems which require a store.

I am passing the store within these as 'mystore'

e.g.


dockedItems:[{
xtype: 'toolbar',
items:[{
fieldLabel:'Search',
xtype:'searchfield',
dock:'top',
store:'mystore',
}]
}]


When logging what the store is passed as within my docked item it receives the string 'mystore' rather than the store itself.

what am I doing wrong?

scottmartin
17 Apr 2012, 7:16 AM
Do you have a storeId: 'mystore' assigned to your store. This adds it to the storeManager so you can reference it by name.. or you can also use



mystore = Ext.data.Store({..})
..
store: mystore // no quotes


With your setup, adding storeId should work.

Regards,
Scott.

Greg_S
17 Apr 2012, 7:47 AM
I forgot to add, the store is defined in folder app/store/myrecordstore.js and extends Ext.data.Store so would that still be correct?

scottmartin
17 Apr 2012, 7:59 AM
That should be fine. You will know right away ;) MVC is basically for organizing your code.

Scott.

Greg_S
17 Apr 2012, 8:07 AM
I have resovled my issue, I updated searchfield to check if it was a string passed, and if it is use
Ext.data.StoreManager.lookup to access the store