Refresh a TreeView After a Node Drop

4 posts, 0 answers
  1. willisk
    willisk avatar
    2 posts
    Member since:
    May 2007

    Posted 12 Aug 2009 Link to this post

    I am trying to Refresh my tree view in an update panel on the right hand side of my page when the user drag's and drop's a single or multiple nodes. on the nodeDrop event it pops up an ajax pop up and takes the quantites for the given node to be dropped, on clicking the ok button it saves it to the database and then i want it to do a refresh on the destination node to bring the new quantities through.

    am using the new web service method because where loading +5000 nodes.

    Protected Sub DataStoreTreeView_NodeDrop(ByVal sender As Object, ByVal e As Telerik.Web.UI.RadTreeNodeDragDropEventArgs)

            Dim sourceNode As RadTreeNode = e.SourceDragNode
            Dim destNode As RadTreeNode = e.DestDragNode
            Dim dropPosition As RadTreeViewDropPosition = e.DropPosition

            Session("SourceDragNode") = sourceNode
            Session("DropPosition") = dropPosition
            Session("DestDragNode") = destNode

            If destNode IsNot Nothing Then
                If sourceNode.TreeView.SelectedNodes.Count <= 1 Then

                    'Capture the Quantity
                    Me.QuantityTextBox.Text = "1"
                    Me.PartListQtyModalPopupExtender.Show()
                    Me.OKButton.Attributes.Add("onFocus", "javascript.this.select();")
                    CType(Master.FindControl("AJAXScriptManager"), ScriptManager).SetFocus(Me.OKButton)
                    Me.DataStoreUpdatePanel.Update()

                    PerformDragAndDrop(dropPosition, sourceNode, destNode)

                ElseIf sourceNode.TreeView.SelectedNodes.Count > 1 Then
                    For Each node As RadTreeNode In sourceNode.TreeView.SelectedNodes

                       'need to sort
                    Next
                End If
            End If

            destNode.Expanded = True
            sourceNode.TreeView.ClearSelectedNodes()
        End Sub

    HERE IS THE OK BUTTON I WANT TO REFRESH AFTER.
     Protected Sub OKButton_Click(ByVal sender As Object, ByVal e As System.EventArgs)
            'Add the dragged item as a new Part List Item

            Dim strDestValue As String = ""
            Dim intEnd As Integer
            ReDim intPLParent(0)

            If CType(Session("DestDragNode"), Telerik.Web.UI.RadTreeNode).Value = "0" Then
                intPLParent(0) = 1
            ElseIf Left(CType(Session("DestDragNode"), Telerik.Web.UI.RadTreeNode).Value, 2) = "PL" Then
                strDestValue = CType(Session("DestDragNode"), Telerik.Web.UI.RadTreeNode).Value
                intEnd = InStr(strDestValue, "~")

                If intEnd > 0 Then
                    intPLParent(0) = Mid(strDestValue, 3, intEnd - 3)
                Else
                    intPLParent(0) = Mid(strDestValue, 3)
                End If
            Else
                strDestValue = CType(Session("DestDragNode"), Telerik.Web.UI.RadTreeNode).Value
                intEnd = InStr(strDestValue, "~")

                If intEnd > 0 Then
                    intPLParent(0) = Mid(strDestValue, 3, intEnd - 3)
                Else
                    intPLParent(0) = Mid(strDestValue, 3)
                End If

            End If

            'Adds the Selected nodes from data store to the DB for creating a PartList.
            AddPartListItem(Session("SourceDragNode"), Session("DropPosition"), Session("DestDragNode"))

            If Me.PartListTreeView.Nodes(0).Nodes.Count > 0 Then
                Me.imgDeletePartList.Visible = True
            Else
                Me.imgDeletePartList.Visible = False
            End If

        End Sub

  2. Yana
    Admin
    Yana avatar
    4994 posts

    Posted 14 Aug 2009 Link to this post

    Hi Wllisk,

    I suggest you use RadAjaxManager and configure it in a way the OK button to update the treeview:

    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"
        <AjaxSettings> 
            <telerik:AjaxSetting AjaxControlID="OKButton"
                <UpdatedControls> 
                    <telerik:AjaxUpdatedControl ControlID="DataStoreTreeView" /> 
                </UpdatedControls> 
            </telerik:AjaxSetting> 
        </AjaxSettings> 
    </telerik:RadAjaxManager> 

    and in the ok button click handler you can rebind the treeview.

    All the best,
    Yana
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. willisk
    willisk avatar
    2 posts
    Member since:
    May 2007

    Posted 14 Aug 2009 Link to this post

    Thank you for your comment yana.

    How would i go about rebinding the treeview as am using the WebService to populate the initial load.

    Regards
  4. Yana
    Admin
    Yana avatar
    4994 posts

    Posted 18 Aug 2009 Link to this post

    Hello Willisk,

    I've attached a very simple page demonstrating the needed approach, it can give you directions how to update the treeview in your project. Please download it and examine it.

    Best regards,
    Yana
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
Back to Top