PDA

View Full Version : Unable to extend Ext.data.JsonStore (proxy null)



alois.cochard
3 Nov 2010, 10:05 PM
Greetings,

I'm trying to extend JsonStore to create reusable component to access my rest service.

The following code works (no extend, in 'onReady'):


var store = Ext.data.JsonStore({
autoDestroy: true,
url: '/decks',
root: 'results',
restful: true,
idProperty: 'id',
mode: 'local',
fields: [{name: 'id', name: 'name'}]
});

store.load();


But when I do this, the store didn't work:


Pomodeck.data.DeckStore = Ext.extend(Ext.data.JsonStore, {
initComponent: function() {
var config = {
autoDestroy: true,
url: '/decks',
root: 'results',
restful: true,
idProperty: 'id',
fields: [{name: 'id', name: 'name'}]
}

Ext.apply(this, Ext.apply(this.initialConfig, config));
Pomodeck.data.DeckStore.superclass.initComponent.apply(this, arguments);
}
});

Ext.onReady(function(){
Ext.QuickTips.init();

var store = new Pomodeck.data.DeckStore();

store.load();
});


After looking inside ext-all-debug.js when doing 'store.load()' the proxy variable is not defined. Seems that some initialization logic isn't processed when extending. Any idea ?

I never experienced such issues when extending other components.

I've tried different 'way' of extending but nothing change, help more than welcome !

Thanks

Alois Cochard
http://aloiscochard.blogspot.com
http://www.twitter.com/aloiscochard

Condor
3 Nov 2010, 11:37 PM
A store isn't a component. It has no initComponent method!

For stores you will need to override the contructor instead.

alois.cochard
4 Nov 2010, 2:38 AM
AAAAH ! Shame on me ... really !

Totally forgot that not everything is Component in ExtJs ... bad Java 'Object' habit :-(

Thanks a lot, now that's rocks

Alois Cochard
http://aloiscochard.blogspot.com
http://www.twitter.com/aloiscochard