1. #1
    Ext JS Premium Member
    Join Date
    Dec 2011
    Posts
    231
    Vote Rating
    2
    nicolabaldo is on a distinguished road

      0  

    Default nested json grid

    nested json grid


    I've this JSON.
    I need to set as dataindex the field "data.field_3.field_3a" in the column of a grid, but It doesn't work.






    "data":[{
    "field_1":1,
    "field_2":2,
    "field_3":{
    "field_3a":1,
    "field_3b":1
    }
    }]




    columns: [
    ...
    {
    xtype: 'gridcolumn',
    dataIndex: data.field_3.field_3a, ??????????
    editor: 'textfield',
    flex: 1,
    text: 'Cliente'
    }
    ...

  2. #2
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    9,197
    Vote Rating
    482
    scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future

      0  

    Default


    See if the following will help:

    Code:
    Ext.onReady(function(){
    
        Ext.create('Ext.data.Store', {
            storeId:'simpsonsStore',
            fields:['name', 'email', 'change', 'extra.fielda'],
            autoLoad: true,
            proxy: {
                type: 'ajax',
                url: 'data.json',
                reader: {
                    type: 'json',
                    root: 'items'
                }
            }
        });
    
        Ext.create('Ext.grid.Panel', {
            title: 'Simpsons',
            store: Ext.data.StoreManager.lookup('simpsonsStore'),
            columns: [
                { header: 'Name',  dataIndex: 'name' },
                { header: 'Email', dataIndex: 'email', flex: 1 },
                { header: 'Change', dataIndex: 'change' },
                { header: 'Change', dataIndex: 'extra.fielda' }
            ],
            height: 200,
            width: 400,
            renderTo: Ext.getBody()
        }); 
    
    });
    Code:
    {
        'items': [
            {
                'name': 'Lisa',
                'email': 'lisa@simpsons.com',
                'change': 100,
                'extra': {
                	fielda: 'lisa-a',
                	fieldb: 'lisa-b'
                }
            },
            {
                'name': 'Bart',
                'email': 'bart@simpsons.com',
                'change': -20,
                'extra': {
                	fielda: 'bart-a',
                	fieldb: 'bart-b'
                }
            },
            {
                'name': 'Homer',
                'email': 'home@simpsons.com',
                'change': 23,
                'extra': {
                	fielda: 'homer-a',
                	fieldb: 'home-b'
                }
            },
            {
                'name': 'Marge',
                'email': 'marge@simpsons.com',
                'change': -11,
                'extra': {
                	fielda: 'marge-a',
                	fieldb: 'marge-b'
                }
            }
        ]
    }
    Regards,
    Scott.

  3. #3
    Ext JS Premium Member
    Join Date
    Dec 2011
    Posts
    231
    Vote Rating
    2
    nicolabaldo is on a distinguished road

      0  

    Default


    Thanks for reply. But I use the model.
    I try to use this as field:
    ...
    {
    mapping: 'extra.fielda',
    name: 'myFielda'
    }
    but It doesn't work.

Thread Participants: 1