Alophind
Alophind

Reputation: 862

How do I add checkbox column to ExtJS 5 grid?

I want to have a checkbox (true/false) for my extjs grid. When I try to add item of xtype : 'checkbox' I get an error :

Uncaught TypeError: column.isColumnHidden is not a function

I've seen on a a post that there is a plugin of checkbox column that needs to be downloaded and included in ExtJS , Isn't there a built in option in ExtJS 5 for checkbox in a grid ?

Upvotes: 2

Views: 14375

Answers (1)

Vladyslav Sheruda
Vladyslav Sheruda

Reputation: 1875

When I use checkbox, I download extjs library from official site and build develompent version of if via extjs console.

My extjs grid with checkbox was look like this:

{
    xtype:'checkcolumn',
    fieldLabel: 'checkbox_label',
    name: 'checkbox_name',
    text: 'text'
}

So full grid code will look like this:

{
    xtype: 'grid',
    frame: true,
    title: 'Users',
    collapsible: true,
    height: 250,
    bind: '{depGrid.selection.users}',
    columns: [
        {
            text: 'Id',
            dataIndex: 'id'
        },
        {
            text: 'Name',
            dataIndex: 'name'
        },
        {
            xtype:'checkcolumn',
            fieldLabel: 'checkbox_label',
            name: 'checkbox_name',
            text: 'text'
        }
    ]
}

Also you cat try to add to checkbox dataIndex field and set to it some boolean variable from your model. Good luck!

Upvotes: 6

Related Questions