Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to dynamically set the grids CheckBox Selection Model in ExtJs4?

This leads on from my previous question.
I initialize a grid with a CheckBox Selection Model, however when I reconfigure the grid the Check Box Selection Model visaully dissapears.
What I want to do is dynamically add a CheckBox Selection Model to a grid after reconfiguring the grids columns, and visually display it.

I have tried something like this:

var sm = new Ext.selection.CheckboxModel();
grid.selModel = sm;
grid.doLayout();
like image 789
shane87 Avatar asked Jun 20 '11 10:06

shane87


1 Answers

This worked for me. SelectionModel dynamic flag

//dynamically change, true or false, as the case 
selectionModel = true

var sm = {} // Selection Model

if (selectionModel){
    sm = Ext.create('Ext.selection.CheckboxModel')
}

var grid = Ext.create('Ext.grid.Panel', {
    selModel: sm,         
    frame: true,
    store: store,
    columns: columns,
    // more code ....
})
like image 60
Roger Pc Avatar answered Nov 13 '22 21:11

Roger Pc