1. #1
    Ext JS Premium Member
    Join Date
    Sep 2008
    Posts
    64
    Vote Rating
    0
    info@ferraresegroup.com is on a distinguished road

      0  

    Default Unanswered: Add colum on gridPanel

    Unanswered: Add colum on gridPanel


    Hi all,
    i'm looking for add column on gridPanel.
    With add method no firebug error appear but layout don't change.


    var grid = new Ext.create('Ext.grid.Panel', {
    title: 'List',
    id: 'grid',
    flex: 1,
    store: 'storeGrid',
    columns: [
    new Ext.grid.RowNumberer(),
    {
    text: 'Prelievo',
    flex: 1,
    columns:[
    { header: "Label a", dataIndex: 'preA', flex:1},
    { header: "Delta", dataIndex: 'preB', flex:1}
    ]
    }
    ]
    });



    var newCol = Ext.create('Ext.grid.column.Column', {
    {
    text: 'New Column',
    flex: 1,
    columns:[
    { header: "Label B", dataIndex: 'preC', flex:1},
    { header: "Delta", dataIndex: 'preD', flex:1}
    ]
    }
    });
    grid.add(newCol);
    grid.doLayout();



    THX

  2. #2
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    9,112
    Answers
    678
    Vote Rating
    470
    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


    In your column object, your are adding an array of columns:

    Try this:
    Code:
    Ext.create('Ext.data.Store', {
        storeId : 'simpsonsStore',
        fields  : ['name', 'email', 'change'],
        data    : {'items' : [
            { 'name' : 'Lisa',  'email' : 'lisa@simpsons.com',  'change' : 100  },
            { 'name' : 'Bart',  'email' : 'bart@simpsons.com',  'change' : -20  },
            { 'name' : 'Homer', 'email' : 'home@simpsons.com',  'change' : 23   },
            { 'name' : 'Marge', 'email' : 'marge@simpsons.com', 'change' : -11  }
        ]},
        proxy   : {
            type   : 'memory',
            reader : {
                type : 'json',
                root : 'items'
            }
        }
    });
    
    var grid = 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'}
        ],
        height     : 200,
        width      : 400,
        renderTo   : Ext.getBody()
    });
    
    Ext.create('Ext.Button', {
        text: 'Click me',
        renderTo: Ext.getBody(),
        handler: function() {
            var column = Ext.create('Ext.grid.column.Column', {header: 'Column'});
            grid.headerCt.insert(grid.columns.length,column);
        }
    });
    Scott

  3. #3
    Ext JS Premium Member
    Join Date
    Sep 2008
    Posts
    64
    Vote Rating
    0
    info@ferraresegroup.com is on a distinguished road

      0  

    Default THX

    THX


    Thanks,
    it work fine.
    Luca F.

Thread Participants: 1

Tags for this Thread