View Full Version : [grid panel] - grid referencing store with an ID/Alias

8 Apr 2014, 2:01 PM
Hi all, I have a question about referencing a Store into a Grid. Usually I do this with giving the Grid an instance of a Store an it works well. Sometimes I see code as in Sencha page (http://www.sencha.com/blog/top-10-ext-js-development-practices-to-avoid), where it references a store as
store: ‘MyStore’. Could you tell me what is
'MyStore'? Is it an alias of a class extending Ext.data.Store? Is it an id of a Store? Thanks for your help!

8 Apr 2014, 11:58 PM
the documentation (http://docs.sencha.com/extjs/4.2.2/#!/api/Ext.grid.Panel-cfg-store) doesnt provide much details. But if you have assigned a storeId to your store, you can use that id in grid and it works. Here is an example taken from the documentation:

Ext.create('Ext.data.Store', {
fields:['name', 'email', 'phone'],
data:[ { 'name': 'Lisa', "email":"[email protected]", "phone":"555-111-1224" } ]

Ext.create('Ext.grid.Panel', {
title: 'Simpsons',
store: 'simpsonsStore',
columns: [
{ header: 'Name', dataIndex: 'name' },
{ header: 'Email', dataIndex: 'email', flex: 1 },
{ header: 'Phone', dataIndex: 'phone' }
height: 200,
width: 400,
renderTo: Ext.getBody()

9 Apr 2014, 12:20 AM
Hi, thanks for your help.

I understand your example, this code seems logical.
The thing is I sometimes see the same code without defining a 'storeId' attribute in the Store, and it still works... I don't understand how.
I should link to an example but I can't remember where I saw it...

9 Apr 2014, 12:22 AM
it could be that it works with aliases too. I haven't tested it.