1 <!DOCTYPE html><html><head><title>Sencha Documentation Project</title><link rel="stylesheet" href="../reset.css" type="text/css"><link rel="stylesheet" href="../prettify.css" type="text/css"><link rel="stylesheet" href="../prettify_sa.css" type="text/css"><script type="text/javascript" src="../prettify.js"></script></head><body onload="prettyPrint()"><pre class="prettyprint"><pre><span id='Ext-grid.plugin.DragDrop'>/**
2 </span> * @class Ext.grid.plugin.DragDrop
3 * <p>This plugin provides drag and/or drop functionality for a GridView.</p>
4 * <p>It creates a specialized instance of {@link Ext.dd.DragZone DragZone} which knows how to drag out of a {@link Ext.grid.View GridView}
5 * and loads the data object which is passed to a cooperating {@link Ext.dd.DragZone DragZone}'s methods with the following properties:<ul>
6 * <li>copy : Boolean
7 * <div class="sub-desc">The value of the GridView's <code>copy</code> property, or <code>true</code> if the GridView was configured
8 * with <code>allowCopy: true</code> <u>and</u> the control key was pressed when the drag operation was begun.</div></li>
9 * <li>view : GridView
10 * <div class="sub-desc">The source GridView from which the drag originated.</div></li>
11 * <li>ddel : HtmlElement
12 * <div class="sub-desc">The drag proxy element which moves with the mouse</div></li>
13 * <li>item : HtmlElement
14 * <div class="sub-desc">The GridView node upon which the mousedown event was registered.</div></li>
15 * <li>records : Array
16 * <div class="sub-desc">An Array of {@link Ext.data.Model Model}s representing the selected data being dragged from the source GridView.</div></li>
17 * </ul></p>
18 * <p>It also creates a specialized instance of {@link Ext.dd.DropZone} which cooperates with other DropZones which are members of the same
19 * ddGroup which processes such data objects.</p>
20 * <p>Adding this plugin to a view means that two new events may be fired from the client GridView, <code>{@link #event-beforedrop beforedrop}</code> and
21 * <code>{@link #event-drop drop}</code></p>
23 Ext.define('Ext.grid.plugin.DragDrop', {
24 extend: 'Ext.AbstractPlugin',
25 alias: 'plugin.gridviewdragdrop',
29 'Ext.grid.ViewDropZone'
32 <span id='Ext-grid.plugin.DragDrop-event-beforedrop'> /**
33 </span> * @event beforedrop
34 * <p><b>This event is fired through the GridView. Add listeners to the GridView object</b></p>
35 * <p>Fired when a drop gesture has been triggered by a mouseup event in a valid drop position in the GridView.
36 * @param {HtmlElement} node The GridView node <b>if any</b> over which the mouse was positioned.</p>
37 * <p>Returning <code>false</code> to this event signals that the drop gesture was invalid, and if the drag proxy
38 * will animate back to the point from which the drag began.</p>
39 * <p>Returning <code>0</code> To this event signals that the data transfer operation should not take place, but
40 * that the gesture was valid, and that the repair operation should not take place.</p>
41 * <p>Any other return value continues with the data transfer operation.</p>
42 * @param {Object} data The data object gathered at mousedown time by the cooperating {@link Ext.dd.DragZone DragZone}'s
43 * {@link Ext.dd.DragZone#getDragData getDragData} method it contains the following properties:<ul>
44 * <li>copy : Boolean
45 * <div class="sub-desc">The value of the GridView's <code>copy</code> property, or <code>true</code> if the GridView was configured
46 * with <code>allowCopy: true</code> and the control key was pressed when the drag operation was begun</div></li>
47 * <li>view : GridView
48 * <div class="sub-desc">The source GridView from which the drag originated.</div></li>
49 * <li>ddel : HtmlElement
50 * <div class="sub-desc">The drag proxy element which moves with the mouse</div></li>
51 * <li>item : HtmlElement
52 * <div class="sub-desc">The GridView node upon which the mousedown event was registered.</div></li>
53 * <li>records : Array
54 * <div class="sub-desc">An Array of {@link Ext.data.Model Model}s representing the selected data being dragged from the source GridView.</div></li>
56 * @param {Ext.data.Model} overModel The Model over which the drop gesture took place.
57 * @param {String} dropPosition <code>"before"</code> or <code>"after"</code> depending on whether the mouse is above or below the midline of the node.
58 * @param {Function} dropFunction <p>A function to call to complete the data transfer operation and either move or copy Model instances from the source
59 * View's Store to the destination View's Store.</p>
60 * <p>This is useful when you want to perform some kind of asynchronous processing before confirming
61 * the drop, such as an {@link Ext.window.MessageBox#confirm confirm} call, or an Ajax request.</p>
62 * <p>Return <code>0</code> from this event handler, and call the <code>dropFunction</code> at any time to perform the data transfer.</p>
65 <span id='Ext-grid.plugin.DragDrop-event-drop'> /**
67 * <b>This event is fired through the GridView. Add listeners to the GridView object</b>
68 * Fired when a drop operation has been completed and the data has been moved or copied.
69 * @param {HtmlElement} node The GridView node <b>if any</b> over which the mouse was positioned.
70 * @param {Object} data The data object gathered at mousedown time by the cooperating {@link Ext.dd.DragZone DragZone}'s
71 * {@link Ext.dd.DragZone#getDragData getDragData} method it contains the following properties:<ul>
72 * <li>copy : Boolean
73 * <div class="sub-desc">The value of the GridView's <code>copy</code> property, or <code>true</code> if the GridView was configured
74 * with <code>allowCopy: true</code> and the control key was pressed when the drag operation was begun</div></li>
75 * <li>view : GridView
76 * <div class="sub-desc">The source GridView from which the drag originated.</div></li>
77 * <li>ddel : HtmlElement
78 * <div class="sub-desc">The drag proxy element which moves with the mouse</div></li>
79 * <li>item : HtmlElement
80 * <div class="sub-desc">The GridView node upon which the mousedown event was registered.</div></li>
81 * <li>records : Array
82 * <div class="sub-desc">An Array of {@link Ext.data.Model Model}s representing the selected data being dragged from the source GridView.</div></li>
84 * @param {Ext.data.Model} overModel The Model over which the drop gesture took place.
85 * @param {String} dropPosition <code>"before"</code> or <code>"after"</code> depending on whether the mouse is above or below the midline of the node.
88 dragText : '{0} selected row{1}',
90 <span id='Ext-grid.plugin.DragDrop-cfg-ddGroup'> /**
91 </span> * @cfg {String} ddGroup
92 * A named drag drop group to which this object belongs. If a group is specified, then both the DragZones and DropZone
93 * used by this plugin will only interact with other drag drop objects in the same group (defaults to 'TreeDD').
95 ddGroup : "GridDD",
97 <span id='Ext-grid.plugin.DragDrop-cfg-dragGroup'> /**
98 </span> * @cfg {String} dragGroup
99 * <p>The ddGroup to which the DragZone will belong.</p>
100 * <p>This defines which other DropZones the DragZone will interact with. Drag/DropZones only interact with other Drag/DropZones
101 * which are members of the same ddGroup.</p>
104 <span id='Ext-grid.plugin.DragDrop-cfg-dropGroup'> /**
105 </span> * @cfg {String} dropGroup
106 * <p>The ddGroup to which the DropZone will belong.</p>
107 * <p>This defines which other DragZones the DropZone will interact with. Drag/DropZones only interact with other Drag/DropZones
108 * which are members of the same ddGroup.</p>
111 <span id='Ext-grid.plugin.DragDrop-cfg-enableDrop'> /**
112 </span> * @cfg {Boolean} enableDrop
113 * <p>Defaults to <code>true</code></p>
114 * <p>Set to <code>false</code> to disallow the View from accepting drop gestures</p>
118 <span id='Ext-grid.plugin.DragDrop-cfg-enableDrag'> /**
119 </span> * @cfg {Boolean} enableDrag
120 * <p>Defaults to <code>true</code></p>
121 * <p>Set to <code>false</code> to disallow dragging items from the View </p>
125 init : function(view) {
126 view.on('render', this.onViewRender, this, {single: true});
129 <span id='Ext-grid.plugin.DragDrop-method-destroy'> /**
131 * AbstractComponent calls destroy on all its plugins at destroy time.
133 destroy: function() {
134 Ext.destroy(this.dragZone, this.dropZone);
137 onViewRender : function(view) {
141 me.dragZone = Ext.create('Ext.view.DragZone', {
143 ddGroup: me.dragGroup || me.ddGroup,
144 dragText: me.dragText
149 me.dropZone = Ext.create('Ext.grid.ViewDropZone', {
151 ddGroup: me.dropGroup || me.ddGroup
155 });</pre></pre></body></html>