Results 1 to 6 of 6

Thread: Load substore in a Grid

  1. #1
    Sencha User
    Join Date
    Oct 2011
    Posts
    20
    Vote Rating
    0
      0  

    Default Answered: Load substore in a Grid

    Hello

    I have an association in my store, i want to load subdata in a grid.

    My models
    Code:
    Ext.define('Zone', {
        extend: 'Ext.data.Model',
        fields: ['id', 'name'],
        hasMany  : {model: 'RefItemZone', name: 'refItems', associationKey:'refItems'}
    });
    
    Ext.define('RefItemZone', {
        extend: 'Ext.data.Model',
        fields: ['link'],
        belongsTo: 'Zone'
    });
    My grid
    Code:
    var grid = Ext.create('Ext.grid.Panel', {
            renderTo: document.body,
            plugins: [rowEditing],
            width: '100%',
            height: window.innerHeight,
            frame: true,
            title: 'Zones',
            store: store,
            collapsible: true,
            columns: [{
                text: 'ID',
                width: 40,
                sortable: true,
                dataIndex: 'id'
            }, {
                text: 'Nom',
                flex: 1,
                sortable: true,
                dataIndex: 'name',
                field: {
                    xtype: 'textfield'
                }
            },{
                text: 'Component',
                flex: 1,
                sortable: true,
                dataIndex: 'SOMETHING THERE',
                field: {
                    xtype: 'textfield'
                }
            }]
    });

    Thank for your help

  2. There are some in the docs for Column and grid.Panel (http://docs.sencha.com/ext-js/4-0/#!....column.Column)

    An other example:

    render: function(value, metaData, record) {
    return value + ' ' + record.get('anythingElse');
    }

  3. #2
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,326
    Answers
    3884
    Vote Rating
    1297
      0  

    Default

    You cannot have two different stores on a grid. The only thing that you can do is when the hasMany store has data, update the record on the main store but that's messy.
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it!

    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  4. #3
    Sencha User
    Join Date
    Oct 2011
    Posts
    20
    Vote Rating
    0
      0  

    Default Store

    Ok but i have only one store with sub store in it.

    Code:
    var store = Ext.create('Ext.data.Store', {
            autoLoad: true,
            autoSync: true,
            sorters: 'id',
            groupField: 'name',
            model: 'Zone',
            proxy: {
                type: 'rest',
                url: '/rest/zones',
                reader: {
                    type: 'json'
                },
                writer: {
                    type: 'json'
                }
            }
        });

    Capture-1.png

  5. #4
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,326
    Answers
    3884
    Vote Rating
    1297
      0  

    Default

    I see... you will need to use a renderer in that case. dataIndex should be the first level key in the record.data Object and then the renderer, the first argument will be the value of that key... you can then traverse down that and return what you want to be displayed. If you need something included in the record, the record is passed as the 3rd argument i believe.
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it!

    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  6. #5
    Sencha User
    Join Date
    Oct 2011
    Posts
    20
    Vote Rating
    0
      0  

    Default

    Ok Thanks !

    Do you have an example of this ?

  7. #6
    Sencha User
    Join Date
    Dec 2009
    Location
    Enschede, The Netherlands
    Posts
    327
    Answers
    16
    Vote Rating
    14
      0  

    Default

    There are some in the docs for Column and grid.Panel (http://docs.sencha.com/ext-js/4-0/#!....column.Column)

    An other example:

    render: function(value, metaData, record) {
    return value + ' ' + record.get('anythingElse');
    }

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
  •