PDA

View Full Version : How can I control the header check event in Ext.selection.CheckboxModel ???



rmorales
15 Feb 2012, 1:10 PM
Hello.

I am using Ext.selection.CheckboxModel in a gridPanel, but I need to have the control of the "header check event" how can I do that???

mbharathiraj
15 Feb 2012, 1:58 PM
Try this below code. You have to override the headerclick function.



Ext.onReady(function() {
Ext.create('Ext.grid.Panel', {
renderTo:Ext.getBody(),
selModel: new Ext.selection.CheckboxModel(),
store: new Ext.data.Store({
fields:['name','company'],
data:[{"name":"xxx","company":"a"},{"name":"yyy","company":"b"}]
}),
columns:[{
text:'Name',
dataIndex:'name'
},{
text:'Compnay',
dataIndex:'company'
}],
listeners:{
render:function() {
this.headerCt.on('headerclick',function(headerCt, header, e){
if (header.isCheckerHd) {
e.stopEvent();
var isChecked = header.el.hasCls(Ext.baseCSSPrefix + 'grid-hd-checker-on');
if (isChecked) {
alert("deselect");
} else {
alert("Select");
}
}
})
}
}
});

});

rmorales
15 Feb 2012, 4:33 PM
Thanks a lot for your fast help, it solves my problem.

I love Ext js, It has the best comunity.

Thanks again.