PDA

View Full Version : More on extending a store ...



keckeroo
8 Nov 2010, 11:56 AM
In ExtJS I used to be able to do the following to create multiple stores with the same info at will :



Ext.ux.profileStore = Ext.extend(Ext.data.Store, {
url: '/ica/icaGetProfile.php',
reader: Ext.gc.profileReader
});

var abc = new Ext.ux.profileStore();
var xyz = new Ext.ux.profileStore();


but the following 'logic' no longer seems to apply in Sencha Touch



Ext.regModel('profileRecord', {
fields: [
{ name: 'userid', mapping: 'UserID' },
{ name: 'account', mapping: 'Account' }
]
});

Ext.ux.profileStore = Ext.extend(Ext.data.Store, {
model: 'profileRecord',
proxy: {
type: 'ajax',
url: '/ica/icaGetProfile.php',
reader: { root: 'records' }
}
});

var abc = new Ext.ux.profileStore();
var xyz = new Ext.ux.profileStore();


I get a runtime error of 'Result of expression: 'this.model' [undefined] is not an object.

Any help would be greatly appreciated on how i can extend a store to easily create multiple
versions of it.

Thank you!

Steffen Hiller
8 Nov 2010, 3:16 PM
Try to pass the model when instantiating the stores:



var abc = new Ext.ux.profileStore({ model: 'profileRecord' });
var xyz = new Ext.ux.profileStore({ model: 'profileRecord' });

Steffen Hiller
8 Nov 2010, 3:20 PM
Actually just tried myself, it works.

If I don't pass it, I get another error than you though:



Uncaught TypeError: Cannot read property 'proxy' of undefined


Either way I would report it as a bug, since I would expect that your code works fine.