Extjs 3.4防止按Ctrl +鼠标点击

问题描述:

我使用Ext.grid.GridPanel从商店中填充我的项目。 一切工作都很好,但我有一个问题。Extjs 3.4防止按Ctrl +鼠标点击

当我按ctrl +鼠标点击网格行,该行取消选择。我怎么能阻止这个动作?在鼠标单击事件和按键按下事件

我试图写入功能

this.grid.onClick = function(event){ 
      if (event.ctrlKey === true){ 
       event.preventDefault(); 
       event.stopPropagation(); 
      } 
     }; 

也试着写return false;,而不是event.preventDefault(); event.stopPropagation();,但没有运气。

有什么建议吗?

找到了一种解决方法。

在RowSelectionModel.js有自定义函数handleMouseDown

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(e.ctrlKey && isSelected){ 
      this.deselectRow(rowIndex); 
     }else if(!isSelected || this.getCount() > 1){ 
      this.selectRow(rowIndex, e.ctrlKey || e.shiftKey); 
      view.focusRow(rowIndex); 
     } 
    } 
}, 

有行

if(e.ctrlKey && isSelected){ 
    this.deselectRow(rowIndex); 
} 

所以我需要重写此功能,并且在有上述添加一些自定义操作。