PDA

View Full Version : singleton = false still makes a singleton



Ronaldo
9 Jan 2012, 1:57 AM
Hi all,

I'm creating my stores like this (below), and I'm explicitely setting the singleton property to false. That's because I want multiple views containing the same entity but with different (server-side) filters.
(Ie a grid with students from grade 1 and a second grid with students from grade 2).
I want each grid to have it's own store.

When I try to create a store, using Ext.create('My.store.StudentStore') I get the message
"[Ext.create] ' 'My.store.StudentStore' is a singleton and cannot be instantiated

But it shouldn't be a singleton, should it?
Is this a bug or am I doing something wrong?

Ronaldo




// Somewhere previously
Ext.ns('My.app');
Mt.url = {
prefix: '/ext/',
list: '/list',
create: '/create',
save: '/save',
remove: '/delete'
};

// And then for every store a file containing

Ext.require('Ext.data.Store');
Ext.require('My.model.Student');
Ext.require('Ext.data.Request');


modelName = 'Student';


Ext.require('My.model.'+modelName);


Ext.define('My.store.'+modelName+'Store', {
extend : 'Ext.data.Store',
singleton : false,
requires : ['My.model.'+modelName],
model : 'My.model.'+modelName,
autoLoad: false,
proxy: {
type: 'ajax',
api: {
read : My.url.prefix + modelName + My.url.list,
create : My.url.prefix + modelName + My.url.create,
update : My.url.prefix + modelName + My.url.save,
destroy : My.url.prefix + modelName + My.url.remove
},
reader: {
type : 'json',
root : 'rows',
totalProperty : 'rowCount',
successProperty: 'success'
}
},
constructor : function() {
this.callParent(arguments);
}
});

evant
9 Jan 2012, 2:44 AM
Thanks, we have a ticket open for this already in our tracker.

Ronaldo
9 Jan 2012, 6:34 AM
Hi,

Thx! Sorry I didn't check the tracker first.
It seems that by not mentioning the singleton property at all, it works just fine.



Ext.define('My.store.'+modelName+'Store', {
extend : 'Ext.data.Store',
// singleton : false,
requires : ['My.model.'+modelName],
model : 'My.model.'+modelName,
autoLoad: false
});