Dec 19, 2011, 12:11 AM
How to check if a tree node is dragged out of a tree
Hi all,
I am now trying to implement a small feature to drag a tree node out of treepanel to delete the node, so that I can remove the toolbar from tree panel.
my solution is to use enddrag listener, but I didn't find out how to check if the tree node is dragged out of the tree(only delete when dragged out). can anybody tell me how to check? or am I using the wrong listener? thanks.
my ascx file is simplified below:
I am now trying to implement a small feature to drag a tree node out of treepanel to delete the node, so that I can remove the toolbar from tree panel.
my solution is to use enddrag listener, but I didn't find out how to check if the tree node is dragged out of the tree(only delete when dragged out). can anybody tell me how to check? or am I using the wrong listener? thanks.
my ascx file is simplified below:
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="CompositeConditionQueryControl.ascx.cs"
Inherits="YTForever.Web.Host.Components.CompositeConditionQueryControl" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Linq" %>
<script type="text/javascript">
var removeNode = function (e, tree) {
//if the node is dragged out of tree, remove it, else return false;
var id;
if (tree.getSelectionModel().getSelectedNode() != null)
id = tree.getSelectionModel().getSelectedNode().id;
else
return false;
DirectX.CompositeConditionQueryControl1.RemoveNode(id, {
success: function (result) {
var nodes = eval(result);
if (nodes.length > 0) {
tree.initChildren(nodes);
tree.root.expand(true, true);
}
else {
tree.getRootNode().removeChildren();
}
}
});
};
</script>
<ext:TreePanel ID="TreePanel1" runat="server" Title="Query" AutoScroll="true" RootVisible="True"
BodyStyle="padding-left:10px" Width="460px" Height="400px" EnableDrag="true">
<Listeners>
<EndDrag Handler="removeNode(e,#{TreePanel1});" />
</Listeners>
</ext:TreePanel>
Last edited by Daniil; Dec 19, 2011 at 8:39 AM.
Reason: Please use [CODE] tags