-
3 Nov 2011 2:39 PM #1
Answered: Error while defining a store
Answered: Error while defining a store
I'm trying to create a simple list with a store in a tab panel and this is the code I did.
The problem is that I get this error: c.model.getProxy si undefinedCode:Ext.define('myApp.model.Test', { extend: 'Ext.data.Model', fields: ['id', 'title', 'cls'] }); Ext.define('myApp.store.Test', { extend: 'Ext.data.Store', config: { model: 'myApp.model.Test', sorters: 'title', getGroupString: function(record) { return record.get('title')[0]; }, proxy: { type: 'memory', reader: { type: 'json', root: 'menu' } }, data : { menu: [{ id: 1, title: 'Element 1', cls: 'clsOne' },{ id: 2, title: 'Element 2', cls: 'clsTwo' }] } } }); Ext.define('myApp.view.Main', { extend: 'Ext.TabPanel', config: { fullscreen: true, tabBarPosition: 'bottom', items: [ { xtype: 'list', title: 'Home', grouped: true, indexBar: true, iconCls: 'star', itemTpl: '{title}', store: Ext.create("myApp.store.Test") } ] } }); Ext.application({ name: 'myApp', launch: function() { var mainPanel = Ext.create('myApp.view.Main').setActiveItem(0); } });
I tried to set the proxy in 'myApp.model.Test' class I created too but nothing worked.
If I create an inline instance of Ext.data.Store with the same code of 'myApp.store.Test' class it works but when I define a class extending a store and I try to create an instance of it, this error always appears.
What did I do wrong?
-
Best Answer Posted by AndreaCammarata
Hi valasquez.
Seems that the "config" object is not actually accepted inside a store definition.
If you put all your store configuration outside the config object everything works fine.
Take a look at the code below:
Hope this helps.Code:Ext.require(['Ext.*']); Ext.application({ name: 'myApp', launch: function() { var data = { menu: [ { id: 1, title: 'Element 2', cls: 'clsOne' }, { id: 2, title: 'Element 1', cls: 'clsTwo' } ] }; Ext.define('myApp.model.Test', { extend: 'Ext.data.Model', fields: ['id', 'title', 'cls'] }); Ext.define('myApp.store.Test', { extend: 'Ext.data.Store', model: 'myApp.model.Test', sorters: 'title', proxy: { type: 'memory', reader: { type: 'json', root: 'menu' } }, data: data, getGroupString: function(record) { return record.get('title')[0]; } }); Ext.define('myApp.view.Main', { extend: 'Ext.TabPanel', config: { fullscreen: true, tabBarPosition: 'bottom', items: [ { xtype: 'list', title: 'Home', grouped: true, indexBar: true, iconCls: 'star', itemTpl: '{title}', store: Ext.create("myApp.store.Test") } ] } }); var mainPanel = Ext.create('myApp.view.Main').setActiveItem(0); } });
-
4 Nov 2011 6:25 AM #2
Hi valasquez.
Seems that the "config" object is not actually accepted inside a store definition.
If you put all your store configuration outside the config object everything works fine.
Take a look at the code below:
Hope this helps.Code:Ext.require(['Ext.*']); Ext.application({ name: 'myApp', launch: function() { var data = { menu: [ { id: 1, title: 'Element 2', cls: 'clsOne' }, { id: 2, title: 'Element 1', cls: 'clsTwo' } ] }; Ext.define('myApp.model.Test', { extend: 'Ext.data.Model', fields: ['id', 'title', 'cls'] }); Ext.define('myApp.store.Test', { extend: 'Ext.data.Store', model: 'myApp.model.Test', sorters: 'title', proxy: { type: 'memory', reader: { type: 'json', root: 'menu' } }, data: data, getGroupString: function(record) { return record.get('title')[0]; } }); Ext.define('myApp.view.Main', { extend: 'Ext.TabPanel', config: { fullscreen: true, tabBarPosition: 'bottom', items: [ { xtype: 'list', title: 'Home', grouped: true, indexBar: true, iconCls: 'star', itemTpl: '{title}', store: Ext.create("myApp.store.Test") } ] } }); var mainPanel = Ext.create('myApp.view.Main').setActiveItem(0); } });Sencha Inc
Andrea Cammarata, Solutions Engineer
CEO at SIMACS
@AndreaCammarata
www.andreacammarata.com
github: https://github.com/AndreaCammarata
-
5 Nov 2011 9:05 PM #3
@andreacammarata is correct. Unfortunately in DP1, the whole Data package (Ext.data.*) is not converted over to the configuration system.


Reply With Quote