ext 中checkbox 无法取消选中行,全选按钮全选问题

1.ext 中checkbox 在选中几个记录时,在单击选中的一行记录,其他选中行会消失的问题,及全选框该不该选中的问题,将下面代码复制到项目中(可能会出现点击gridpanel 的行的时候,无法选中的问题,请看描述2)

Ext.override(Ext.grid.RowSelectionModel, {
			selectRow : function(B, D, A) {
			  if(this.singleSelect==false){
					if (this.locked || (B < 0 || B >= this.grid.store.getCount())
							|| this.isSelected(B)) {
						return;
					}
					var C = this.grid.store.getAt(B);
					if (this.fireEvent("beforerowselect", this, B, D, C) !== false) {
						if (!D) {
							this.selections.remove(C);
						} else {
							this.selections.add(C);
							this.last = this.lastActive = B;
						}
						if (D) {
							this.grid.getView().onRowSelect(B);
						}
						this.fireEvent("rowselect", this, B, C);
						this.fireEvent("selectionchange", this)
					}
			  }else{
					 if(this.locked || (B < 0 || B >= this.grid.store.getCount()) || this.isSelected(B)) return;
				        var r = this.grid.store.getAt(B);
				        if(r && this.fireEvent("beforerowselect", this, B, D, r) !== false){
				            if(!D || this.singleSelect){
				                this.clearSelections();
				            }
				            this.selections.add(r);
				            this.last = this.lastActive = B;
				            if(!A){
				                this.grid.getView().onRowSelect(B);
				            }
				            this.fireEvent("rowselect", this, B, r);
				            this.fireEvent("selectionchange", this);
				        }
				
			  }
				
			}
			,
			handleMouseDown : function(g, rowIndex, e) {
				if (e.button !== 0 || this.isLocked()) {
					return;
				}
				var view = this.grid.getView();
				if (e.shiftKey && !this.singleSelect && this.last !== false) {
					var last = this.last;
					this.selectRange(last, rowIndex, e.ctrlKey);
					this.last = last; // reset the last
					view.focusRow(rowIndex);
				} else {
					var isSelected = this.isSelected(rowIndex);
					if (!isSelected) {
						this.deselectRow(rowIndex)
					} else {
						this.selectRow(rowIndex, true);
						view.focusRow(rowIndex);
					}
				}
			}
          
		});


2.解决 添加了 问题 1 的 代码,gridpanel 中点击行无法获得选中值的问题

//具体事件名称可以根据需要自己写, 这里只是提供一个思路, 这里实现的是 点击一行(该行有点击事件,只能监听你 该行用renderer 赋值的列)
Ext.override(Ext.grid.GridPanel,{
    listeners:{
      cellmousedown:function (grid,rowIndex,columnIndex,e){
          var selectm=grid.getSelectionModel();
          selectm.clearSelections();
          selectm.selectRow(rowIndex, true);
      }
    
    }
});


评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值