This is a migrated thread and some comments may be shown as answers.

Dragging a node, selects the node

1 Answer 33 Views
This is a migrated thread and some comments may be shown as answers.
jamie ooms
Top achievements
Rank 1
jamie ooms asked on 17 Jun 2010, 03:52 PM

Im trying the trail of Telerik currently. I'm very pleased with ur product and we will most likely buy a developer licence soon.
I have a question.

When dragging a node is it possible to not select the node.


I have a treeview with lots of nodes. A user can select a node and then the details screen is shown on the right.
When a node is selected the user can drag another node to a grid on the right screen.

The problem i have is that the node that was left clicked should stay selected.
But when u start to drag another node, this dragged node gets the selected style.

Is it possible to leave the selected style to the node that was left clicked?

Thanks in advance

1 Answer, 1 is accepted

Sort by
Nikolay Tsenkov
Telerik team
answered on 23 Jun 2010, 12:29 PM
Hi Jamie,

Sorry for the late response!
I've tried to compensate this by providing you with full example just for your requirements.

It holds one constraint (my solution), though:
- You have to use the NodeClicked event to remember the last clicked node (in the solution I am trapping it client-side, by you can use the server-side if needed);

Anyway, I think that you already have implemented it as required and even if you didn't it will be fairly easy to migrate (just to handle different event with the same handler).

Here is the complete example:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<head runat="server">
    <form id="form1" runat="server">
    <asp:ScriptManager runat="server">
    <script type="text/javascript">
        var lastSelectedNode;
        function onNodeClicked(sender,args)
            var label=$telerik.$("#label");
            label.text(lastSelectedNode.get_text() + "clicked!");
        function onNodeDragging(sender,args)
        function onNodeDropped(sender,args)
            var tree=sender;
            var destinationNodeDomElement =;
            var destinationNode=tree._extractNodeFromDomElement(destinationNodeDomElement);
            var destinationNodeNodes=destinationNode.get_nodes();
            var droppedNodes = args.get_sourceNodes();
            var droppedNodesCount = droppedNodes.length;
            for(var i=0;i<droppedNodesCount;i++)
    <telerik:RadTreeView runat="server" ID="treeView" EnableDragAndDrop="true" OnClientNodeClicked="onNodeClicked" OnClientNodeDragging="onNodeDragging" OnClientNodeDropped="onNodeDropped">
            <telerik:RadTreeNode AllowDrag="false" Text="Root">
                    <telerik:RadTreeNode Text="Child 1" />
                    <telerik:RadTreeNode Text="Child 2" />
                    <telerik:RadTreeNode Text="Child 3" />
                    <telerik:RadTreeNode Text="Child 4" />
                    <telerik:RadTreeNode Text="Child 5" />
                    <telerik:RadTreeNode Text="Child 6" />
        <asp:Label runat="server" ID="label" />

Hope this is going to help you!

Nikolay Tsenkov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Asked by
jamie ooms
Top achievements
Rank 1
Answers by
Nikolay Tsenkov
Telerik team
Share this question