extjs4 CheckboxModel全选

时间:2013-07-17 12:06:39

标签: extjs checkbox grid

我希望CheckboxModel在呈现网格时全部显示:
enter image description here

这是我的代码:

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

网格:

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

2 个答案:

答案 0 :(得分:2)

您可以使用网格的 afterrender 侦听器来选择所有行:

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

答案 1 :(得分:2)

afterrender可能无效,请尝试afterlayout

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