2

I'm trying to do this:

...
store: ZAdmin.store.TreeFactory.create('ZAdmin.model.Category', 'Application\\Entity\\Category')
...

But getting:

...    
store: 'ZAdmin.store.TreeFactory.create(\'ZAdmin.model.Category\', \'Application\\Entity\\Category\')'
...

There is no way to change store from string to object type.

How to fix it?

P.S. I'm about editing config properties in GUI. Sencha Architect assumes store to be a string, so auto-escapes any value.

4orever
  • 105
  • 6

2 Answers2

0

store config takes store object or its name, so in case you want to pass an object you can either create it in-place OR in initialize method you can do this:

var myStore = ZAdmin.store.TreeFactory.create('ZAdmin.model.Category', 'Application\\Entity\\Category'); // Any kind of store creation
this.setStore(myStore);
myStore.load();   // Optional

having late store association/load gives you advantage of quickly showing the view without waiting for data to load.

ThinkFloyd
  • 4,981
  • 6
  • 36
  • 56
0

If you are keen to keep the initialisation in the definition then the best bet if you create an override class for your object. I.e. on the top of the code edit window press the "Create override" button then enter your own initialisation code there under config. E.g. if you want to set a dataview object's store on this way then create the override for the dataview with a code like this:

Ext.define('MyApp.view.MyDataView', {
extend: 'Ext.dataview.DataView',

config: {
    store: ZAdmin.store.TreeFactory.create('ZAdmin.model.Category', 'Application\\Entity\\Category')
}
});

To be able to override your control on this way you need to promote it to class first (right click in the control -> promote to class -> create override for the newly created class).

Zoltan Magyar
  • 874
  • 1
  • 6
  • 19
  • Thank you. Finally I decided to create factories for trees and grids and then call the store factory from the view factory. – 4orever Jan 28 '13 at 19:43