Aminesrine
Aminesrine

Reputation: 2140

extjs4 CheckboxModel select all

I want that the CheckboxModel appear all checked when grid is rendered:
enter image description here

This is my code:

sm = Ext.create('Ext.selection.CheckboxModel', {
        listeners: {
            selectionchange: function (sm, selections) {
                // Must refresh the view after every selection
                sm.view.refresh();
            }
        }
    })

The grid:

{
            xtype: 'gridpanel',
            title: 'gridTitle',
            selModel: sm,
            store: my_store,
            columns: {
                items:[
                    ..
                ]
            }
        }

Upvotes: 3

Views: 4974

Answers (2)

Max Podriezov
Max Podriezov

Reputation: 1098

afterrender may not work, try afterlayout instead:

// in your grid
listeners: {
    afterlayout : function (thisObj, eOpts) {
       thisObj.getSelectionModel().selectAll();
    }
},
// ...

Upvotes: 2

Dev
Dev

Reputation: 3932

You could use afterrender listeners of the grid to select all the rows :

 listeners:{
    afterrender:function( thisObj, eOpts ){
        var sm=thisObj.getSelectionModel();
        sm.selectAll(true);
    }
},

Upvotes: 2

Related Questions