Duplicate Nodes getting added

6 posts, 0 answers
  1. Madhu
    Madhu avatar
    20 posts
    Member since:
    Jan 2008

    Posted 01 Jul 2008 Link to this post

    Hi,

    I have two treeview controls, one is the source and another is the destination.
    I populate the source treeview control dynamically only on first page load i.e not on Postback, like

    If Not IsPostback() then

    PopulateSourceTreeview()    ' Private subroutine to populate treeview               dynamically.

    End If

    But what's happening is once I drag a node from source to destination, some nodes in Source treeview is getting duplicated, i.e it's again being added, especially the ones that have child node. But the one which don't have child nodes are not getting duplicated.

    thnx
  2. Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 01 Jul 2008 Link to this post

    Hi Madhu,

    I am not sure where the problem comes from. Did you try tracing the drag and drop operation with the debugger? Maybe this would show why the nodes are duplicated. Additionally you can check this online example which demonstrates similar.

    Regards,
    Albert
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Madhu
    Madhu avatar
    20 posts
    Member since:
    Jan 2008

    Posted 01 Jul 2008 Link to this post

    Yes. I started the debugger too, but couldn't figure it out.
    Here are my code snippets:

    <

    table width=80% border=0 cellpadding=3 class=maintable2 align="center">

    <tr>

    <td>

    <telerik:RadTreeView ID="RadTvwSource" runat="server" DragAndDrop="true" DragAndDropBetweenNodes="true" MultipleSelect="true" Skin="Vista">

    </telerik:RadTreeView>

    </td>

    <td style="width:5px">&nbsp;</td>

    <td>

    <telerik:RadTreeView ID="RadTvwDestination" runat="server" DragAndDrop="true" DragAndDropBetweenNodes="true"

    MultipleSelect="true" Skin="Vista">

    </telerik:RadTreeView>

    </td>

    </tr>

    </table>


    .aspx.vb code
    -----------------

    Protected Sub RadTvwSource_NodeDrop(ByVal o As Object, ByVal e As Telerik.WebControls.RadTreeNodeEventArgs) Handles      RadTvwSource.NodeDrop

            If e.SourceDragNode.Category = e.DestDragNode.Category Then
                Dim sScript1 As String = ""
                sScript1 = "<Script language='javascript'>"
                sScript1 += "alert('You cannot add a source node over the destination node of same type category.')"
                sScript1 += "</script>"
                Page.RegisterClientScriptBlock("", sScript1)

                Exit Sub
            End If

            e.DestDragNode.Nodes.Add(e.SourceDragNode)
           
    End Sub

    Protected

    Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    objCoreLibCapacityManagement =

    New core180Lib.core180Lib.core180CapacityManagement(strConnDB)

    If Not IsPostBack Then

    populateSiteList()

    LoadRackTemplates()

    End If

    End Sub

    Private Sub populateSiteList()

    ddSites.Items.Clear()

    ddSites.DataSource = objCoreLibCapacityManagement.getSiteList()

    ddSites.DataTextField =

    "SiteName"

    ddSites.DataValueField =

    "SiteID"

    ddSites.DataBind()

    ddSites.Items.Insert(0,

    New ListItem("--Select--", ""))

    End Sub

    Private Sub LoadRackTemplates()

    RadTvwSource.Nodes.Clear()

    Dim dt As DataTable = objCoreLibCapacityManagement.getRackTemplateListForSiteEquipment()

    For Each row As DataRow In dt.Rows

    Dim node As New RadTreeNode()

    node.Text = row(

    "RackLabel")

    node.Value = row(

    "RackTemplateID")

    node.Category = row(

    "TemplateType")

    If CInt(row("ChildCount")) > 0 Then

    node.ExpandMode = ExpandMode.ServerSideCallBack

    End If

    RadTvwSource.Nodes.Add(node)

    Next

     

    'RadTreeView1.DataSource = objCoreLibCapacityManagement.getRackTemplateList()

    'RadTreeView1.DataTextField = "RackLabel"

    'RadTreeView1.DataValueField = "RackTemplateID"

    'RadTreeView1.DataBind()

    End Sub

    Protected Sub RadTvwSource_NodeExpand(ByVal o As Object, ByVal e As Telerik.WebControls.RadTreeNodeEventArgs) Handles RadTvwSource.NodeExpand

    'Dim strTemplateType As String = e.NodeClicked.Category

    Dim dt As DataTable

    Select Case e.NodeClicked.Category

    Case "RACK"

    dt = objCoreLibCapacityManagement.getShelfTemplateListForSiteEquipment(e.NodeClicked.Value)

    Case "SHELF"

    dt = objCoreLibCapacityManagement.getCardTemplateListForSiteEquipment(e.NodeClicked.Value)

    End Select

    If Not dt Is Nothing Then

    For Each row As DataRow In dt.Rows

    Dim node As New RadTreeNode()

    node.Text = row(

    "Text")

    node.Value = row(

    "Value")

    node.Category = row(

    "TemplateType")

    If CInt(row("ChildCount")) > 0 Then

    node.ExpandMode = ExpandMode.ServerSideCallBack

    End If

    e.NodeClicked.Nodes.Add(node)

    Next

    End If

     

    End Sub

    Protected Sub ddSites_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddSites.SelectedIndexChanged

     

    RadTvwDestination.Nodes.Clear()

    Dim RootNode As New RadTreeNode()

    RootNode.Text = ddSites.SelectedItem.Text

    RootNode.Value = ddSites.SelectedValue

    RootNode.Category =

    "SITE"

    RadTvwDestination.Nodes.Add(Rootnode)

    Dim dt As DataTable

    dt = objCoreLibCapacityManagement.getRackInstancesList(ddSites.SelectedValue)

    If Not dt Is Nothing Then

    For Each row As DataRow In dt.Rows

    Dim node As New RadTreeNode()

    node.Text = row(

    "Text")

    node.Value = row(

    "Value")

    node.Category = row(

    "TemplateType")

    If CInt(row("ChildCount")) > 0 Then

    node.ExpandMode = ExpandMode.ServerSideCallBack

    End If

    RootNode.Nodes.Add(node)

    Next

    End If

    End Sub



    thnx


  5. Madhu
    Madhu avatar
    20 posts
    Member since:
    Jan 2008

    Posted 01 Jul 2008 Link to this post

    Also I have one more problem. When I drag and drop a node from source to the destination treeview and change the style of newly created node on destination view  , the style of the corresponding dragged node from source treeview also changes which I don't want.

  6. Madhu
    Madhu avatar
    20 posts
    Member since:
    Jan 2008

    Posted 01 Jul 2008 Link to this post

    What is the link for online help of RadTreeview control for ASP.NET Ajax
  7. Mallverkstan
    Mallverkstan avatar
    20 posts
    Member since:
    May 2007

    Posted 16 Dec 2008 Link to this post

    I had a similar problem. This thread helped: http://www.telerik.com/community/forums/aspnet-ajax/treeview/call-node-expand-on-demand-more-than-once.aspx
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017