-
21 Mar 2012 5:03 PM #1
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'); } } } });
-
22 Mar 2012 11:01 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,656
- Vote Rating
- 435
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.
-
29 Mar 2012 5:08 AM #3
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:
Then, in just this one tested case, everything works fine.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'); } } } });
-
9 Oct 2012 6:26 AM #4
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'); } } } });


Reply With Quote