PDA

View Full Version : How to get the header checkbox (selectall) event on a selection model



rafaelrp
16 Mar 2012, 3:48 AM
I need to call functions on this event but i've searched and i doesn't find any answer..


var checkboxes = Ext.create("Ext.selection.CheckboxModel");

Thanks ~o)

vietits
16 Mar 2012, 6:09 AM
As I known with Ext 4.0.7, Ext.selection.CheckboxModel (and Ext.selection.Model in general) does not fire 'selectall' event.

chramer
16 Mar 2012, 6:51 AM
if you need it really bad, you can override "onHeaderClick" method like so :

var sm = Ext.create('Ext.selection.CheckboxModel', {
onHeaderClick: function (headerCt, header, e) {
if (header.isCheckerHd) {
e.stopEvent();
var isChecked = header.el.hasCls(Ext.baseCSSPrefix + 'grid-hd-checker-on');
if (isChecked) {
this.deselectAll(true);
//YOUR CODE ON UNCHECK
console.log('all unchecked');
} else {
this.selectAll(true);
//YOUR CODE ON CHECK
console.log('all checked');
}
}
}
});
Check it out here! http://jsfiddle.net/serju/SDtpR/1/

rafaelrp
16 Mar 2012, 12:17 PM
I need to put this event on a listener..


Ext.getCmp("panelGrid").getSelectionModel().on("onheaderclick", function(selModel, record, index){ //rec = Ext.getCmp("panelGrid").store.getAt(index);
Ext.Msg.alert("Selecao", "Aham...");
//clearMarker(index);
});

but doesn't work...

chramer
16 Mar 2012, 12:40 PM
you've put a listener.. when do you want to fire it ?

rafaelrp
19 Mar 2012, 6:02 AM
I want to fire it when i click on the checkbox on header(selectall checkbox)

chramer
19 Mar 2012, 6:16 AM
once again :


var sm = Ext.create('Ext.selection.CheckboxModel', {
onHeaderClick: function (headerCt, header, e) {
if (header.isCheckerHd) {
e.stopEvent();
var isChecked = header.el.hasCls(Ext.baseCSSPrefix + 'grid-hd-checker-on');
if (isChecked) {
this.deselectAll(true);
} else {
this.selectAll(true);

//POST THE CODE TO EXECUTE WHEN ALL ARE CHECKED

alert('all checked');
}
}
}
});????

rafaelrp
19 Mar 2012, 9:03 AM
I'm trying to add markers on a google map (all markers), on console a enter this function

Ext.getCmp("panelGrid").selModel.selectAll()

but into the code i have no sucess, the points doesn't appear on the map

//checkbox do gridvar checkboxes = Ext.create('Ext.selection.CheckboxModel', {
onHeaderClick: function (headerCt, header, e) {
if (header.isCheckerHd) {
e.stopEvent();
var isChecked = header.el.hasCls(Ext.baseCSSPrefix + 'grid-hd-checker-on');
if (isChecked) {
this.deselectAll(true);
Ext.getCmp("panelGrid").selModel.deselectAll()
console.log('all unchecked');
} else {
this.selectAll(true);
Ext.getCmp("panelGrid").selModel.selectAll();
console.log('all checked');
}
}
}
});

Thanks! ~o)

helloaccp
27 Aug 2012, 10:57 PM
HI How to get the header checkbox (selectall) event on a selection model to solve it?