grid checkbox 多选问题.. (更改为 点击条目 实现多选 )

1. 覆盖原方法
Ext.override(Ext.grid.CheckboxSelectionModel, {
		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 if (!isSelected || this.getCount() > 1) {
					this.selectRow(rowIndex, true);
					view.focusRow(rowIndex);
				}
			}
		}
	});


2. 使用创建 子对象的方式 :  (不会影响 原来的定义)
Ext.namespace('Ext.xz');     
	      
	Ext.xz.CheckboxSelectionModel =function(config)     
	{     
	    Ext.xz.CheckboxSelectionModel.superclass.constructor.call(this,config);     
	    this.group = config.group;     
	    this.value=config.value;     
	};     
	
	// 实现点击内容可多选
	Ext.extend(Ext.xz.CheckboxSelectionModel, Ext.grid.CheckboxSelectionModel,{
		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 if (!isSelected || this.getCount() > 1) {
					this.selectRow(rowIndex, true);
					view.focusRow(rowIndex);
				}
			}
		}
	});

你可能感兴趣的:(ext)