PDA

View Full Version : [CLOSED] StoreManager seems to ignore the StoreId



steffen.rahn
9 Feb 2012, 4:53 AM
I have the following simplyfied setup


Ext.define('MY.store.Cls', {
extend: 'Ext.data.Store',
autoLoad: true,
storeId: 'Cl',
proxy: {
type: 'direct',
model: 'MY.model.Cl',
api: {
read: Cl.List
},
reader: {
type: 'json',
root: 'data'
}
},
initComponent: function () {
this.callParent(arguments);
}
});



Ext.define('MY.controller.Dt', {
extend: 'Ext.app.Controller',
views: ['dt.Grid', 'dt.New', 'dt.Edit'],
stores: ['Dts', 'Cls'],
models: ['Dt', 'Cl']
});

but when I type Ext.StoreMgr.lookup('Cl'); in firebug I get a undefined while Ext.StoreMgr.lookup('Cls'); returns the instance. Know I thought that the storemanager would take the storeId defined in the storeclass but it seems to take the storename as defined in the controller?

mitchellsimoens
9 Feb 2012, 1:54 PM
Ext.define('MY.store.Cls', {
extend: 'Ext.data.Store',
storeId: 'Cl',
proxy: {
type: 'direct',
model: 'MY.model.Cl',
/*api: {
read: Cl.List
},*/
reader: {
type: 'json',
root: 'data'
}
},
initComponent: function () {
this.callParent(arguments);
}
});

I took autoLoad out and had to comment the api out but I was able to do Ext.getStore('Cl') and get the instance.

Also note that initComponent is only used on Components. Stores are not components.

steffen.rahn
10 Feb 2012, 1:32 AM
I've set a breakpoint into the StoreManager register method and took a look into the store config of each store that gets registered. All storeId's are overridden by the name of the store. I don't have the time to digg deeper, but here is a runable example. It just needs a environment with ExtJS 4.0.7 and will show nothing, but if you try Ext.getStore('Entity'); you will get undefined while Ext.getStore('Entitys'); will fetch the store... Dunno, for me it looks like a bug.


Ext.app.REMOTING_API = {
"url": "/NewDemo/Direct/Router/",
"type": "remoting",
"actions": {
"Entity": [{
"name": "List",
"len": 1
}]
}
};
Ext.direct.Manager.addProvider(Ext.app.REMOTING_API);

Ext.define('MY.model.Entity', {
extend: 'Ext.data.Model',
idProperty: 'Id',
fields: [{
name: 'Id',
type: 'int'
}]
});

Ext.define('MY.store.Entitys', {
extend: 'Ext.data.Store',
remoteSort: true,
autoLoad: true,

proxy: {
type: 'direct',
model: 'MY.model.Entity',
api: {
read: Entity.List
},
reader: {
type: 'json',
root: 'data'
}
},

storeId: 'Entity'
});

Ext.define('MY.view.entity.Grid', {
extend: 'Ext.grid.Panel',
alias: 'widget.entitygrid',
store: 'Entitys',
title: 'Entity',
autoScroll: true,
initComponent: function () {
this.columns = [{
header: 'Id',
dataIndex: 'Id'
}];
this.callParent(arguments);
}
});

Ext.define('MY.controller.Entity', {
extend: 'Ext.app.Controller',

views: ['entity.Grid'],
stores: ['Entitys'],
models: ['Entity'],

init: function () {

}

});

Ext.BLANK_IMAGE_URL = 'Content/lib/img/s.gif';
Ext.application({
name: 'MY',
controllers: ['Entity'],

launch: function () {


}
});

steffen.rahn
13 Feb 2012, 11:33 PM
I still wait for a answer. The democode above should clearify that it seems to be issue/bug. And if so could you please move this to the bug section?

jsakalos
14 Feb 2012, 3:26 AM
Hmmm, it seems like a valid bug report to me. Do you want this thread to be moved to Bugs so that developers can pick it up?

steffen.rahn
19 Feb 2012, 11:52 PM
Bump-up...
Still waiting for feedback. Verify/Decline?

evant
20 Feb 2012, 12:36 AM
This is by design, the Controller automatically sets the storeId when creating the instance of it.

colin.yates
2 Mar 2012, 2:18 AM
Not according to the documentation either in the 4.0.7 download or the live documentation at http://docs.sencha.com/ext-js/4-0/#!/api/Ext.data.Store, which states:



//this store can be used several times Ext.create (http://docs.sencha.com/ext-js/4-0/#%21/api/Ext-method-create)('Ext.data.Store (http://docs.sencha.com/ext-js/4-0/#%21/api/Ext.data.Store)', { model: 'User', storeId: 'usersStore' }); new Ext.List({ store: 'usersStore', //other config goes here }); new Ext.view.View (http://docs.sencha.com/ext-js/4-0/#%21/api/Ext.view.View)({ store: 'usersStore', //other config goes here });