PDA

View Full Version : How to lock checkbox column?



vicvolk87
11 Jun 2013, 11:59 AM
Hello, Sencha-guys!) Please help, I'm in truble. I guess there should be a simple solution to my problem. I have a grid with a checkbox model. Is it possible to lock this column? The grid can contain many-many columns and sometimes the user has to scroll to the right to see something and depending on the data this user may or may not check the row. So he has to scroll back to do this. Just clicking on the row is not a way out, because cells may be editable or contain some hypertext.

chamacs
11 Jun 2013, 12:07 PM
Available since 4.1.1, grid panel columns have a locked:true attribute:
http://docs.sencha.com/extjs/4.1.1/#!/api/Ext.grid.column.Column-cfg-locked
(http://docs.sencha.com/extjs/4.1.1/#!/api/Ext.grid.column.Column-cfg-locked)
Is this what you're looking for?

vicvolk87
11 Jun 2013, 12:11 PM
Hi, chamacs (http://www.sencha.com/forum/member.php?247844-chamacs)!
I tried to use this property in this way



var selModel=Ext.create('Ext.selection.CheckboxModel',{
locked : true
});


But it leads to an error.

chamacs
11 Jun 2013, 12:18 PM
The attribute needs to be put on the column config, not the selection model. What is it you're trying to do? This attribute will lock the column in place so scrolling to the right will not move the column.

psuedo example:


Ext.create('Ext.grid.Panel', {
store : // your store ref
columns: [{
text: 'Name',
dataIndex: 'name',
locked : true,
width : 100
}, {
text: 'Email',
dataIndex: 'email',
flex : 1
}]
});

vicvolk87
11 Jun 2013, 12:25 PM
This is the minified version of the code I have. What I want is to lock the very first checkbox column added by the model. It is not present inside "columns" block. So, I can't use "locked:true" just in a standard manner.



var selModel=Ext.create('Ext.selection.CheckboxModel',{});
var grid = Ext.create('Ext.grid.Panel', {
store: store,
selModel: selModel,
columnLines: true,
columns: [{
text : 'Company Name',
dataIndex: 'company'
},{
text : 'Price',
dataIndex: 'price'
}]
});

vicvolk87
11 Jun 2013, 12:32 PM
I want to lock this column, marked by an arrow. This makes sense, when there is too much columns in a grid. And the user wants to check a particular row, depending on the data somewhere to the right of the grid.

44312

slemmon
13 Jun 2013, 1:31 PM
I believe you'll need to create an overrride for the checkbox selection model. If you look at the private getHeaderConfig method you can see where locking is set on the column header config.

There is a request in for the header to be optionally locked (outside of having locked peers) in the feature request queue internally, so perhaps in some future build that will be a public config option.