2 * @class Ext.view.DragZone
3 * @extends Ext.dd.DragZone
6 Ext.define('Ext.view.DragZone', {
7 extend: 'Ext.dd.DragZone',
8 containerScroll: false,
10 constructor: function(config) {
13 Ext.apply(me, config);
15 // Create a ddGroup unless one has been configured.
16 // User configuration of ddGroups allows users to specify which
17 // DD instances can interact with each other. Using one
18 // based on the id of the View would isolate it and mean it can only
19 // interact with a DropZone on the same View also using a generated ID.
21 me.ddGroup = 'view-dd-zone-' + me.view.id;
24 // Ext.dd.DragDrop instances are keyed by the ID of their encapsulating element.
25 // So a View's DragZone cannot use the View's main element because the DropZone must use that
26 // because the DropZone may need to scroll on hover at a scrolling boundary, and it is the View's
27 // main element which handles scrolling.
28 // We use the View's parent element to drag from. Ideally, we would use the internal structure, but that
29 // is transient; DataView's recreate the internal structure dynamically as data changes.
30 // TODO: Ext 5.0 DragDrop must allow multiple DD objects to share the same element.
31 me.callParent([me.view.el.dom.parentNode]);
33 me.ddel = Ext.get(document.createElement('div'));
34 me.ddel.addCls(Ext.baseCSSPrefix + 'grid-dd-wrap');
37 init: function(id, sGroup, config) {
38 this.initTarget(id, sGroup, config);
39 this.view.mon(this.view, {
40 itemmousedown: this.onItemMouseDown,
45 onItemMouseDown: function(view, record, item, index, e) {
46 if (!this.isPreventDrag(e, record, item, index)) {
47 this.handleMouseDown(e);
51 // private template method
52 isPreventDrag: function(e) {
56 getDragData: function(e) {
58 item = e.getTarget(view.getItemSelector()),
59 record, selectionModel, records;
62 record = view.getRecord(item);
63 selectionModel = view.getSelectionModel();
64 records = selectionModel.getSelection();
66 copy: this.view.copy || (this.view.allowCopy && e.ctrlKey),
67 event: new Ext.EventObjectImpl(e),
72 fromPosition: Ext.fly(item).getXY()
77 onInitDrag: function(x, y) {
81 selectionModel = view.getSelectionModel(),
82 record = view.getRecord(data.item),
85 // Update the selection to match what would have been selected if the user had
86 // done a full click on the target node rather than starting a drag from it
87 if (!selectionModel.isSelected(record) || e.hasModifier()) {
88 selectionModel.selectWithEvent(record, e);
90 data.records = selectionModel.getSelection();
92 me.ddel.update(me.getDragText());
93 me.proxy.update(me.ddel.dom);
98 getDragText: function() {
99 var count = this.dragData.records.length;
100 return Ext.String.format(this.dragText, count, count == 1 ? '' : 's');
103 getRepairXY : function(e, data){
104 return data ? data.fromPosition : false;