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

e.SourceDragNode is Nothing

3 Answers 17 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
çağlar
Top achievements
Rank 1
çağlar asked on 11 Sep 2013, 09:18 AM
Hi,

I'm using RadTreeView(Q2 2013 SP1) control with templated nodes. My aspx page is like that;

<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
    <div>
    
        <telerik:RadTreeView ID="RadTreeView1" Runat="server" EnableDragAndDrop="True" 
            EnableDragAndDropBetweenNodes="True" OnNodeDrop="RadTreeView1_HandleDrop" EnableViewState="false">
            <Nodes>
                <telerik:RadTreeNode runat="server" Text="Genel Müdür A">
                    <Nodes>
                        <telerik:RadTreeNode runat="server" Text="Genel Müdür Yardımcısı A" >
                        <NodeTemplate>
                            <table>
                                <tr>
                                    <td>
                                        <asp:Label ID="Label1" runat="server" Text="isim"></asp:Label></td>
                                    <td>
                                        <telerik:RadTextBox ID="RadTextBox1" runat="server">
                                        </telerik:RadTextBox></td>
                                </tr>
                            </table>
                        </NodeTemplate>
                        </telerik:RadTreeNode>
                    </Nodes>
                </telerik:RadTreeNode>
                <telerik:RadTreeNode runat="server" Text="Genel Müdür B">
                    <Nodes>
                        <telerik:RadTreeNode runat="server" Text="Genel Müdür Yardımcısı B" >
                        <NodeTemplate>
                            <table>
                                <tr>
                                    <td>
                                        <asp:Label ID="Label1" runat="server" Text="isim"></asp:Label></td>
                                    <td>
                                        <telerik:RadTextBox ID="RadTextBox1" runat="server">
                                        </telerik:RadTextBox></td>
                                </tr>
                            </table>
                        </NodeTemplate>
                        </telerik:RadTreeNode>
                    </Nodes>
                </telerik:RadTreeNode>
            </Nodes>
        </telerik:RadTreeView>
    
    </div>
    </form>
</body> 

and also aspx.vb is;

Protected Sub RadTreeView1_HandleDrop(ByVal sender As Object, ByVal e As RadTreeNodeDragDropEventArgs)
        Dim sourceNode As RadTreeNode = e.SourceDragNode
        Dim destNode As RadTreeNode = e.DestDragNode
        Dim dropPosition As RadTreeViewDropPosition = e.DropPosition

        If destNode IsNot Nothing Then
            'drag&drop is performed between trees

            'dropped node will be a sibling of the destination node
            If sourceNode.TreeView.SelectedNodes.Count <= 1 Then
                PerformDragAndDrop(dropPosition, sourceNode, destNode)
            ElseIf sourceNode.TreeView.SelectedNodes.Count > 1 Then
                For Each node As RadTreeNode In RadTreeView1.SelectedNodes
                    If Not node.IsAncestorOf(destNode) Then
                        PerformDragAndDrop(dropPosition, sourceNode, destNode)
                    End If
                Next
            End If


            destNode.Expanded = True
            sourceNode.TreeView.UnselectAllNodes()
            RadTreeView1.DataBind()

        End If
    End Sub

    Private Shared Sub PerformDragAndDrop(ByVal dropPosition As RadTreeViewDropPosition, ByVal sourceNode As RadTreeNode, ByVal destNode As RadTreeNode)
        If sourceNode.Equals(destNode) OrElse sourceNode.IsAncestorOf(destNode) Then
            Return
        End If
        sourceNode.Owner.Nodes.Remove(sourceNode)

        Select Case dropPosition
            Case RadTreeViewDropPosition.Over
                ' child
                If Not sourceNode.IsAncestorOf(destNode) Then
                    destNode.Nodes.Add(sourceNode)
                End If
                Exit Select

            Case RadTreeViewDropPosition.Above
                ' sibling - above                         
                destNode.InsertBefore(sourceNode)
                Exit Select

            Case RadTreeViewDropPosition.Below
                ' sibling - below
                destNode.InsertAfter(sourceNode)
                Exit Select
        End Select
    End Sub

I'm trying to drag and drop templated nodes but in my first try it looses the template controls' values and at the second time i got the error message-  e.SourceDragNode is Nothing.

please help..

3 Answers, 1 is accepted

Sort by
0
Kate
Telerik team
answered on 16 Sep 2013, 08:19 AM
Hi,

Please try calling the RadTreeView's DataBind() method at the end of the TreeDrop handler and let me know if this helps.

Regards,
Kate
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
0
çağlar
Top achievements
Rank 1
answered on 16 Sep 2013, 09:08 AM
Hi Kate,

I'm also callind RadTreeView DataBind() method at the end of HandleDrop but it doesn't work.

do you have any other solution ?

thanks
0
Kate
Telerik team
answered on 23 Sep 2013, 12:27 PM
Hello çağlar,

I noticed that you also opened a support ticket that I have just answered. I will also paste my reply in this post in case anyone else is looking for a similar solution.  Below you can find a very detailed forum post where you can find very good explanation on the issue that you currently encounter - Drag and drop in RadTreeView replaces template with text.

Regards,
Kate
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Tags
TreeView
Asked by
çağlar
Top achievements
Rank 1
Answers by
Kate
Telerik team
çağlar
Top achievements
Rank 1
Share this question
or