PDA

View Full Version : [CLOSED] TreeViewDragDrop plugin on over event



Leonid_Veriga
Sep 12, 2012, 10:28 AM
Hello.

I am trying to use a TreeViewDragDrop plugin for nodes reordering. I have nodes of different types, and nodes of one type could not be dropped to nodes of other type. I was abble to implement this using BeforeDrop listener (I return false, when types are different). However I did not find any way to show user, that this drop operation is not allowed (no Over listener).

Could you suggest a way to solve this issue?

Best regards.

Daniil
Sep 12, 2012, 12:37 PM
Hi Leonid,

Unfortunately, there is no built-in option to change this behavior.

But I can suggest to override the isValidDropPoint function of the ViewDropZone class.
http://docs.sencha.com/ext-js/4-1/source/ViewDropZone2.html#Ext-tree-ViewDropZone-method-isValidDropPoint

Example

<%@ Page Language="C#" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>

<!DOCTYPE html>

<html>
<head runat="server">
<title>Ext.NET v2 Example</title>

<script type="text/javascript">
var onAfterRender = function (view) {
var dz = view.getPlugin("dragdrop").dropZone;

dz.isValidDropPoint = Ext.Function.createInterceptor(dz.isValidDropPoint , function (node, position, dragZone, e, data) {
return false; // please implement as you need
});
};
</script>
</head>
<body>
<ext:ResourceManager runat="server" />

<ext:TreePanel runat="server">
<Root>
<ext:Node Text="Root (level 0)" Expanded="true">
<Children>
<ext:Node Text="Node1 (level 1)" Expanded="true">
<Children>
<ext:Node Text="Node1 (level 2)" Expanded="true">
<Children>
<ext:Node Text="Node1 (level 3)" Leaf="true" />
<ext:Node Text="Node2 (level 3)" Leaf="true" />
</Children>
</ext:Node>
</Children>
</ext:Node>
</Children>
</ext:Node>
</Root>
<View>
<ext:TreeView runat="server">
<Plugins>
<ext:TreeViewDragDrop PluginId="dragdrop" runat="server" />
</Plugins>
<Listeners>
<AfterRender Fn="onAfterRender" />
</Listeners>
</ext:TreeView>
</View>
</ext:TreePanel>
</body>
</html>

Leonid_Veriga
Sep 12, 2012, 2:38 PM
Thank you, Daniil. This works perfect.

Daniil
Dec 21, 2012, 7:39 AM
You may be interested to look at this example.
http://examples2.ext.net/#/TreePanel/Basic/Custom_Drop_Logic/