Results 1 to 4 of 4

Thread: Use checkboxSelectionModel on dragDrop enabled grid

  1. #1
    Sencha - Services Team Stju's Avatar
    Join Date
    Dec 2008
    Location
    Redwood city, California
    Posts
    293

    Default Use checkboxSelectionModel on dragDrop enabled grid

    Problem: I want to use checkboxSelectionModel on dragDrop enabled grid, but can't uncheck checkbox after row is selected.

    Solution: use overrides provided.

    Code:
        // Override for situation, where both drag drop and checkbox selection models are used, you can't deselect checkbox
    
        Ext.override(Ext.dd.DragSource,{
            handleMouseDown: function(e) {
    
                if(Ext.get(e.target.id).hasCls('x-grid-row-checker')){
                    return false;
                }
    
                if (this.dragging) {
                    return;
                }
                var data = this.getDragData(e);
                if (data && this.onBeforeDrag(data, e) !== false) {
                    this.dragData = data;
                    this.proxy.stop();
                    this.callParent(arguments);
                }
            }
        });
    
    
        Ext.override(Ext.view.DragZone,{
            onItemMouseDown: function(view, record, item, index, e) {
    
                if (!this.isPreventDrag(e, record, item, index)) {
                    this.handleMouseDown(e);
    
                    // If we want to allow dragging of multi-selections, then veto the following handlers (which, in the absence of ctrlKey, would deselect)
                    // if the mousedowned record is selected
    
                     if (view.getSelectionModel().selectionMode == 'MULTI' && !e.ctrlKey && view.getSelectionModel().isSelected(record)) {
                         return Ext.get(e.target.id).hasCls('x-grid-row-checker');
                     }
                }
            }
        });

  2. #2
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,379

    Default

    Free info from Sencha!
    Mitchell Simoens @LikelyMitch

    Check out my GitHub:
    https://github.com/mitchellsimoens

    Posts are my own, not any current, past or future employer's.

  3. #3
    Sencha User
    Join Date
    Dec 2009
    Location
    Enschede, The Netherlands
    Posts
    327

    Default

    I've been running into the same thing, so thnx for the post. In my specific case (using 4.1 rc1) it didn't work without changing to:

    Code:
    // Override for situation, where both drag drop and checkbox selection models are used, you can't deselect checkbox
    
    
    Ext.override(Ext.dd.DragSource,{
    	handleMouseDown: function(e) {
    		var element = Ext.get(e.target.id);
    
    
    		if(element != null && element.hasCls('x-grid-row-checker')){
    			return false;
    		}
    
    
    		if (this.dragging) {
    			return;
    		}
    		var data = this.getDragData(e);
    		if (data && this.onBeforeDrag(data, e) !== false) {
    			this.dragData = data;
    			this.proxy.stop();
    			this.callParent(arguments);
    		}
    	}
    });
    
    
    
    
    Ext.override(Ext.view.DragZone,{
        onItemMouseDown: function(view, record, item, index, e) {
    		var element;
    
    
            if (!this.isPreventDrag(e, record, item, index)) {
                this.handleMouseDown(e);
    
    
                // If we want to allow dragging of multi-selections, then veto the following handlers (which, in the absence of ctrlKey, would deselect)
                // if the mousedowned record is selected
    
    
    			element = Ext.get(e.target.id);
    			if (element != null && view.getSelectionModel().selectionMode == 'MULTI' && !e.ctrlKey && view.getSelectionModel().isSelected(record)) {
    				return element.hasCls('x-grid-row-checker');
    			}
            }
        }
    });
    Then, in just this one tested case, everything works fine.

  4. #4

    Default

    In my case i have to take off the id from target:
    Code:
    Ext.override(Ext.dd.DragSource,{
                    handleMouseDown: function(e) {
                        
                        if(Ext.get(e.target).hasCls('x-grid-row-checker')){
                            return false;
                        }
            
                        if (this.dragging) {
                            return;
                        }
                        var data = this.getDragData(e);
                        if (data && this.onBeforeDrag(data, e) !== false) {
                            this.dragData = data;
                            this.proxy.stop();
                            this.callParent(arguments);
                        }
                    }
                });
    
    
                Ext.override(Ext.view.DragZone,{
                    onItemMouseDown: function(view, record, item, index, e) {
            
                        if (!this.isPreventDrag(e, record, item, index)) {
                            this.handleMouseDown(e);
            
                            // If we want to allow dragging of multi-selections, then veto the following handlers (which, in the absence of ctrlKey, would deselect)
                            // if the mousedowned record is selected
            
                             if (view.getSelectionModel().selectionMode == 'MULTI' && !e.ctrlKey && view.getSelectionModel().isSelected(record)) {
                                 return Ext.get(e.target).hasCls('x-grid-row-checker');
                             }
                        }
                    }
                });

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •