1. #1
    Sencha User
    Join Date
    Mar 2014
    Posts
    10
    Answers
    2
    Vote Rating
    1
    IAmAndre is on a distinguished road

      0  

    Default Unanswered: Adding a particular column to a Grid

    Unanswered: Adding a particular column to a Grid


    Hi,

    I'm showing a set of results in my application with a Grid (Ext.grid.Panel) and I want to add a particular column containing buttons. When I try to, I get the following error :
    TypeError: headers[i].setSortState is not a function

    I guess it has something to do with the fact that the others column are linked to a Store, while this one is not and therefore can't be sorted. Here is my code :

    Code:
    Ext.define('App.view.UsersGrid',{
        extend:'Ext.grid.Panel',
        store: Ext.data.StoreManager.lookup('usersStore'),
        columns: [
            { text: 'Username', dataIndex: 'username', flex: 100/3},
            { text: 'Level', dataIndex: 'level', flex: 100/3},
            {
                text: 'Actions',
                xtype:'buttongroup',
                iconflex: 100/3,
                items: [
                    {
                        xtype:'button',
                        icon:'resources/images/add_user.png'
                    }
                ]
            }
        ]
    });
    I would like to add a set of buttons at every line. The buttons will be the same at every line, but I might need help to set the controllers too, I mean making sure that every button will trigger an action but taking into account the line it is related to.

    Thanks

  2. #2
    Sencha Premium Member skirtle's Avatar
    Join Date
    Oct 2010
    Location
    UK
    Posts
    3,593
    Answers
    541
    Vote Rating
    324
    skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future

      2  

    Default


    The problem is that your grid column isn't actually a column. ButtonGroup doesn't extend Ext.grid.column.Column.

    ActionColumn provides something similar to what you're trying to do. If you really want to use button components you'll need to use a UX, e.g.:

    http://www.sencha.com/forum/showthread.php?148064

    Unrelated, you can simplify this:

    Code:
    store: Ext.data.StoreManager.lookup('usersStore'),
    to just:

    Code:
    store: 'usersStore',
    I think you've mistyped iconflex.

    Also, flexes aren't percentage, they're proportions relative to each other, so there's no need to have values like 100/3. If you want them all to be the same width then just set them all to 1.

  3. #3
    Sencha User
    Join Date
    Mar 2014
    Posts
    10
    Answers
    2
    Vote Rating
    1
    IAmAndre is on a distinguished road

      0  

    Default


    Thank you very much for your help. I also figured out how to use the handlers to trigger specific actions, like this :
    Code:
    handler: function(grid, rowIndex, colIndex) {
    It's working fine but I'd like to use a controller. Thanks

Thread Participants: 1

Tags for this Thread