Upgrade to ExtJS 4.0.0 - Released 04/26/2011
[extjs.git] / docs / source / DragDrop2.html
diff --git a/docs/source/DragDrop2.html b/docs/source/DragDrop2.html
new file mode 100644 (file)
index 0000000..a58c654
--- /dev/null
@@ -0,0 +1,155 @@
+<!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'>/**
+</span> * @class Ext.grid.plugin.DragDrop
+ * &lt;p&gt;This plugin provides drag and/or drop functionality for a GridView.&lt;/p&gt;
+ * &lt;p&gt;It creates a specialized instance of {@link Ext.dd.DragZone DragZone} which knows how to drag out of a {@link Ext.grid.View GridView}
+ * and loads the data object which is passed to a cooperating {@link Ext.dd.DragZone DragZone}'s methods with the following properties:&lt;ul&gt;
+ * &lt;li&gt;copy : Boolean
+ *  &lt;div class=&quot;sub-desc&quot;&gt;The value of the GridView's &lt;code&gt;copy&lt;/code&gt; property, or &lt;code&gt;true&lt;/code&gt; if the GridView was configured
+ *  with &lt;code&gt;allowCopy: true&lt;/code&gt; &lt;u&gt;and&lt;/u&gt; the control key was pressed when the drag operation was begun.&lt;/div&gt;&lt;/li&gt;
+ * &lt;li&gt;view : GridView
+ *  &lt;div class=&quot;sub-desc&quot;&gt;The source GridView from which the drag originated.&lt;/div&gt;&lt;/li&gt;
+ * &lt;li&gt;ddel : HtmlElement
+ *  &lt;div class=&quot;sub-desc&quot;&gt;The drag proxy element which moves with the mouse&lt;/div&gt;&lt;/li&gt;
+ * &lt;li&gt;item : HtmlElement
+ *  &lt;div class=&quot;sub-desc&quot;&gt;The GridView node upon which the mousedown event was registered.&lt;/div&gt;&lt;/li&gt;
+ * &lt;li&gt;records : Array
+ *  &lt;div class=&quot;sub-desc&quot;&gt;An Array of {@link Ext.data.Model Model}s representing the selected data being dragged from the source GridView.&lt;/div&gt;&lt;/li&gt;
+ * &lt;/ul&gt;&lt;/p&gt;
+ * &lt;p&gt;It also creates a specialized instance of {@link Ext.dd.DropZone} which cooperates with other DropZones which are members of the same
+ * ddGroup which processes such data objects.&lt;/p&gt;
+ * &lt;p&gt;Adding this plugin to a view means that two new events may be fired from the client GridView, &lt;code&gt;{@link #event-beforedrop beforedrop}&lt;/code&gt; and
+ * &lt;code&gt;{@link #event-drop drop}&lt;/code&gt;&lt;/p&gt;
+ */
+Ext.define('Ext.grid.plugin.DragDrop', {
+    extend: 'Ext.AbstractPlugin',
+    alias: 'plugin.gridviewdragdrop',
+
+    uses: [
+        'Ext.view.DragZone',
+        'Ext.grid.ViewDropZone'
+    ],
+
+<span id='Ext-grid.plugin.DragDrop-event-beforedrop'>    /**
+</span>     * @event beforedrop
+     * &lt;p&gt;&lt;b&gt;This event is fired through the GridView. Add listeners to the GridView object&lt;/b&gt;&lt;/p&gt;
+     * &lt;p&gt;Fired when a drop gesture has been triggered by a mouseup event in a valid drop position in the GridView.
+     * @param {HtmlElement} node The GridView node &lt;b&gt;if any&lt;/b&gt; over which the mouse was positioned.&lt;/p&gt;
+     * &lt;p&gt;Returning &lt;code&gt;false&lt;/code&gt; to this event signals that the drop gesture was invalid, and if the drag proxy
+     * will animate back to the point from which the drag began.&lt;/p&gt;
+     * &lt;p&gt;Returning &lt;code&gt;0&lt;/code&gt; To this event signals that the data transfer operation should not take place, but
+     * that the gesture was valid, and that the repair operation should not take place.&lt;/p&gt;
+     * &lt;p&gt;Any other return value continues with the data transfer operation.&lt;/p&gt;
+     * @param {Object} data The data object gathered at mousedown time by the cooperating {@link Ext.dd.DragZone DragZone}'s
+     * {@link Ext.dd.DragZone#getDragData getDragData} method it contains the following properties:&lt;ul&gt;
+     * &lt;li&gt;copy : Boolean
+     *  &lt;div class=&quot;sub-desc&quot;&gt;The value of the GridView's &lt;code&gt;copy&lt;/code&gt; property, or &lt;code&gt;true&lt;/code&gt; if the GridView was configured
+     *  with &lt;code&gt;allowCopy: true&lt;/code&gt; and the control key was pressed when the drag operation was begun&lt;/div&gt;&lt;/li&gt;
+     * &lt;li&gt;view : GridView
+     *  &lt;div class=&quot;sub-desc&quot;&gt;The source GridView from which the drag originated.&lt;/div&gt;&lt;/li&gt;
+     * &lt;li&gt;ddel : HtmlElement
+     *  &lt;div class=&quot;sub-desc&quot;&gt;The drag proxy element which moves with the mouse&lt;/div&gt;&lt;/li&gt;
+     * &lt;li&gt;item : HtmlElement
+     *  &lt;div class=&quot;sub-desc&quot;&gt;The GridView node upon which the mousedown event was registered.&lt;/div&gt;&lt;/li&gt;
+     * &lt;li&gt;records : Array
+     *  &lt;div class=&quot;sub-desc&quot;&gt;An Array of {@link Ext.data.Model Model}s representing the selected data being dragged from the source GridView.&lt;/div&gt;&lt;/li&gt;
+     * &lt;/ul&gt;
+     * @param {Ext.data.Model} overModel The Model over which the drop gesture took place.
+     * @param {String} dropPosition &lt;code&gt;&quot;before&quot;&lt;/code&gt; or &lt;code&gt;&quot;after&quot;&lt;/code&gt; depending on whether the mouse is above or below the midline of the node.
+     * @param {Function} dropFunction &lt;p&gt;A function to call to complete the data transfer operation and either move or copy Model instances from the source
+     * View's Store to the destination View's Store.&lt;/p&gt;
+     * &lt;p&gt;This is useful when you want to perform some kind of asynchronous processing before confirming
+     * the drop, such as an {@link Ext.window.MessageBox#confirm confirm} call, or an Ajax request.&lt;/p&gt;
+     * &lt;p&gt;Return &lt;code&gt;0&lt;/code&gt; from this event handler, and call the &lt;code&gt;dropFunction&lt;/code&gt; at any time to perform the data transfer.&lt;/p&gt;
+     */
+
+<span id='Ext-grid.plugin.DragDrop-event-drop'>    /**
+</span>     * @event drop
+     * &lt;b&gt;This event is fired through the GridView. Add listeners to the GridView object&lt;/b&gt;
+     * Fired when a drop operation has been completed and the data has been moved or copied.
+     * @param {HtmlElement} node The GridView node &lt;b&gt;if any&lt;/b&gt; over which the mouse was positioned.
+     * @param {Object} data The data object gathered at mousedown time by the cooperating {@link Ext.dd.DragZone DragZone}'s
+     * {@link Ext.dd.DragZone#getDragData getDragData} method it contains the following properties:&lt;ul&gt;
+     * &lt;li&gt;copy : Boolean
+     *  &lt;div class=&quot;sub-desc&quot;&gt;The value of the GridView's &lt;code&gt;copy&lt;/code&gt; property, or &lt;code&gt;true&lt;/code&gt; if the GridView was configured
+     *  with &lt;code&gt;allowCopy: true&lt;/code&gt; and the control key was pressed when the drag operation was begun&lt;/div&gt;&lt;/li&gt;
+     * &lt;li&gt;view : GridView
+     *  &lt;div class=&quot;sub-desc&quot;&gt;The source GridView from which the drag originated.&lt;/div&gt;&lt;/li&gt;
+     * &lt;li&gt;ddel : HtmlElement
+     *  &lt;div class=&quot;sub-desc&quot;&gt;The drag proxy element which moves with the mouse&lt;/div&gt;&lt;/li&gt;
+     * &lt;li&gt;item : HtmlElement
+     *  &lt;div class=&quot;sub-desc&quot;&gt;The GridView node upon which the mousedown event was registered.&lt;/div&gt;&lt;/li&gt;
+     * &lt;li&gt;records : Array
+     *  &lt;div class=&quot;sub-desc&quot;&gt;An Array of {@link Ext.data.Model Model}s representing the selected data being dragged from the source GridView.&lt;/div&gt;&lt;/li&gt;
+     * &lt;/ul&gt;
+     * @param {Ext.data.Model} overModel The Model over which the drop gesture took place.
+     * @param {String} dropPosition &lt;code&gt;&quot;before&quot;&lt;/code&gt; or &lt;code&gt;&quot;after&quot;&lt;/code&gt; depending on whether the mouse is above or below the midline of the node.
+     */
+
+    dragText : '{0} selected row{1}',
+
+<span id='Ext-grid.plugin.DragDrop-cfg-ddGroup'>    /**
+</span>     * @cfg {String} ddGroup
+     * A named drag drop group to which this object belongs.  If a group is specified, then both the DragZones and DropZone
+     * used by this plugin will only interact with other drag drop objects in the same group (defaults to 'TreeDD').
+     */
+    ddGroup : &quot;GridDD&quot;,
+
+<span id='Ext-grid.plugin.DragDrop-cfg-dragGroup'>    /**
+</span>     * @cfg {String} dragGroup
+     * &lt;p&gt;The ddGroup to which the DragZone will belong.&lt;/p&gt;
+     * &lt;p&gt;This defines which other DropZones the DragZone will interact with. Drag/DropZones only interact with other Drag/DropZones
+     * which are members of the same ddGroup.&lt;/p&gt;
+     */
+
+<span id='Ext-grid.plugin.DragDrop-cfg-dropGroup'>    /**
+</span>     * @cfg {String} dropGroup
+     * &lt;p&gt;The ddGroup to which the DropZone will belong.&lt;/p&gt;
+     * &lt;p&gt;This defines which other DragZones the DropZone will interact with. Drag/DropZones only interact with other Drag/DropZones
+     * which are members of the same ddGroup.&lt;/p&gt;
+     */
+
+<span id='Ext-grid.plugin.DragDrop-cfg-enableDrop'>    /**
+</span>     * @cfg {Boolean} enableDrop
+     * &lt;p&gt;Defaults to &lt;code&gt;true&lt;/code&gt;&lt;/p&gt;
+     * &lt;p&gt;Set to &lt;code&gt;false&lt;/code&gt; to disallow the View from accepting drop gestures&lt;/p&gt;
+     */
+    enableDrop: true,
+
+<span id='Ext-grid.plugin.DragDrop-cfg-enableDrag'>    /**
+</span>     * @cfg {Boolean} enableDrag
+     * &lt;p&gt;Defaults to &lt;code&gt;true&lt;/code&gt;&lt;/p&gt;
+     * &lt;p&gt;Set to &lt;code&gt;false&lt;/code&gt; to disallow dragging items from the View &lt;/p&gt;
+     */
+    enableDrag: true,
+
+    init : function(view) {
+        view.on('render', this.onViewRender, this, {single: true});
+    },
+
+<span id='Ext-grid.plugin.DragDrop-method-destroy'>    /**
+</span>     * @private
+     * AbstractComponent calls destroy on all its plugins at destroy time.
+     */
+    destroy: function() {
+        Ext.destroy(this.dragZone, this.dropZone);
+    },
+
+    onViewRender : function(view) {
+        var me = this;
+
+        if (me.enableDrag) {
+            me.dragZone = Ext.create('Ext.view.DragZone', {
+                view: view,
+                ddGroup: me.dragGroup || me.ddGroup,
+                dragText: me.dragText
+            });
+        }
+
+        if (me.enableDrop) {
+            me.dropZone = Ext.create('Ext.grid.ViewDropZone', {
+                view: view,
+                ddGroup: me.dropGroup || me.ddGroup
+            });
+        }
+    }
+});</pre></pre></body></html>
\ No newline at end of file