PDA

View Full Version : CheckBox selectionModel enable/disable selection



mirkotus
6 Jan 2014, 5:50 AM
How can I dynamically disable/enable checkboxes on the checkbox Selection model that is used by my grid. I tried the following but it did not work:


onButtonClick: function() { var grid = Ext.getCmp('grid'); grid.getSelectionModel.setLocked(); }

scottmartin
8 Jan 2014, 3:11 PM
This seems to work as expected:



Ext.onReady(function(){

Ext.create('Ext.data.Store', {
storeId:'simpsonsStore',
fields:['name', 'email', 'phone'],
data:{'items':[
{ 'name': 'Lisa', "email":"lisa@simpsons.com", "phone":"555-111-1224" },
{ 'name': 'Bart', "email":"bart@simpsons.com", "phone":"555-222-1234" },
{ 'name': 'Homer', "email":"home@simpsons.com", "phone":"555-222-1244" },
{ 'name': 'Marge', "email":"marge@simpsons.com", "phone":"555-222-1254" }
]},
proxy: {
type: 'memory',
reader: {
type: 'json',
root: 'items'
}
}
});

var sm = new Ext.selection.CheckboxModel({
mode: 'multi'
});

var grid = Ext.create('Ext.grid.Panel', {
title: 'Simpsons',
store: Ext.data.StoreManager.lookup('simpsonsStore'),
columns: [
{ text: 'Name', dataIndex: 'name', editor: { xtype: 'textfield'} },
{ text: 'Email', dataIndex: 'email', flex: 1 },
{ text: 'Phone', dataIndex: 'phone' }
],
height: 200,
width: 400,
selModel: sm,
renderTo: Ext.getBody()
});

setTimeout(function(){
sm.setLocked(true); // you have 3 seconds to check something
},3000);

});