全选和取消选择的控制,扩展CheckboxSelectionModel即可, 对JS语法不太熟悉,琢磨了好久才完成.
Merry Christmas!?
if (Ext.grid.CheckboxSelectionModel) {
?var interceptOnMouseDown = Ext.grid.CheckboxSelectionModel.prototype.onMouseDown.createInterceptor(function(e, t){
???this.on('rowdeselect', this.handleDeselect, this);
???this.on('rowselect', this.handleSelect, this);???
??}?
?);
?
?Ext.override(Ext.grid.CheckboxSelectionModel, {
??hd : null,?? ??
??? onMouseDown : interceptOnMouseDown,?????
??? handleSelect:function(){
????? if(this.grid.store.getCount()!=this.selections.length)
????return;?
??? var hd = Ext.fly(this.grid.getView().innerHd).child('div.x-grid3-hd-checker');
????? if(!hd.hasClass('x-grid3-hd-checker-on'))??
??? ??hd.addClass('x-grid3-hd-checker-on');
??? },???
??? handleDeselect:function(){
??? ? if( this.grid.store.getCount() != this.selections.length +1)
????return;?
????? var hd = Ext.fly(this.grid.getView().innerHd).child('div.x-grid3-hd-checker');?
????? if(hd.hasClass('x-grid3-hd-checker-on'))
??? ?? hd.removeClass('x-grid3-hd-checker-on');
??? }
?});?
}