Question

i`m using Ext.grid.GridPanel to populate my items from stores. Everything is working quite good, but i have one problem.

When i press ctrl + mouse click on grids row, the row deselects. How could i prevent this action?

I have tried writing function on mouse click event and key down event

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

also tried writing return false; instead of event.preventDefault(); event.stopPropagation(); but with no luck.

Any suggestions?

Was it helpful?

Solution

Found one workaround.

in RowSelectionModel.js there is custom function 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);
        }
    }
},

there is lines

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

So i needed to override this function and add some custom actions in above mentioned if.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top