Results 1 to 4 of 4

Thread: [grid panel] - grid referencing store with an ID/Alias

  1. #1
    Sencha User toni07's Avatar
    Join Date
    Oct 2013
    Posts
    16

    Default [grid panel] - grid referencing store with an ID/Alias

    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, where it references a store as
    Code:
    store: MyStore
    . Could you tell me what is
    Code:
    'MyStore'
    ? Is it an alias of a class extending Ext.data.Store? Is it an id of a Store? Thanks for your help!

  2. #2
    Touch Premium Member
    Join Date
    Jun 2011
    Posts
    1,102
    Answers
    113

    Default

    the documentation 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:

    Code:
    Ext.create('Ext.data.Store', {
        storeId:'simpsonsStore',
        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()
    });

  3. #3
    Sencha User toni07's Avatar
    Join Date
    Oct 2013
    Posts
    16

    Default

    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...

  4. #4
    Touch Premium Member
    Join Date
    Jun 2011
    Posts
    1,102
    Answers
    113

    Default

    it could be that it works with aliases too. I haven't tested it.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •