1. #1
    Sencha - Services Team Stju's Avatar
    Join Date
    Dec 2008
    Location
    Redwood city, California
    Posts
    276
    Vote Rating
    0
    Stju is on a distinguished road

      0  

    Default Use checkboxSelectionModel on dragDrop enabled grid

    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 - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    St. Louis, MO
    Posts
    33,656
    Vote Rating
    435
    mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of

      0  

    Default


    Free info from Sencha!
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    http://www.JSONPLint.com - Source to lint your JSONP!

    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Sencha User
    Join Date
    Dec 2009
    Location
    Enschede, The Netherlands
    Posts
    327
    Vote Rating
    11
    flanders will become famous soon enough

      0  

    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
    Sencha User
    Join Date
    Sep 2012
    Posts
    1
    Vote Rating
    0
    UelitonFreitas is on a distinguished road

      0  

    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');
                             }
                        }
                    }
                });