Server Side Move code example updated for VS2005 - Not working.

5 posts, 0 answers
  1. Bob
    Bob avatar
    55 posts
    Member since:
    Apr 2008

    Posted 16 Sep 2008 Link to this post

    The example from this post is for an older version of the tree.  http://www.telerik.com/community/code-library/submission/b311D-dhkhe.aspx

    My updated code is not working.  Any ideas?


    Try

    Select Case e.MenuItem.Text.ToLower

    Case "delete"

    e.Node.Remove()

    statusLabel.Text =

    "You deleted " & e.Node.Text

    ' save the changes

     

    Case "move up"

    'move the selected node one place up

    'here's what we're gonna do:

    'Check if this node is already at the top

    'If not, switch it with the node directly above him, same goes for moving the node down...

    If Not e.Node.Value = e.Node.ParentNode.Nodes(0).Value Then

    Dim i As Integer = 0

    While i < e.Node.ParentNode.Nodes.Count

    If e.Node.Value = e.Node.ParentNode.Nodes(i).Value Then

    'Because of the i-value, we are going to 'walk' through the

    'second layer of the tree (radtreeview1.nodes(0).nodes)

    'This part is a bit nasty programming, first we remove the node before the node we want to move

    'our nodeclicked is now automatically moving one place up,

    'than we insert the removed node one place under the moved node

    'et voila

    Dim tempNode As New Telerik.Web.UI.RadTreeNode

    tempNode = e.Node.ParentNode.Nodes(i - 1)

    m_RadTreeFolderHierarchy.Nodes(0).Nodes.RemoveAt(i - 1)

    m_RadTreeFolderHierarchy.Nodes(0).Nodes.Insert(i, tempNode)

    End If

    i += 1

    End While

    End If

    Case "move down"

    'move the selected node one place down

    If Not e.Node.Value = e.Node.ParentNode.Nodes(e.Node.ParentNode.Nodes.Count - 1).Value Then

    Dim i As Integer = 0

    While i < e.Node.ParentNode.Nodes.Count

    If e.Node.Value = e.Node.ParentNode.Nodes(i).Value Then

    'Because of the i-value, we are going to 'walk' through the

    'second layer of the tree (radtreeview1.nodes(0).nodes)

    'This part is a bit nasty programming, first we remove the node AFTER the node we want to move

    'our nodeclicked is now automatically moving one place down,

    'than we insert the removed node one place ABOVE the moved node

    'et voila

    Dim tempNode As New Telerik.Web.UI.RadTreeNode

    tempNode = e.Node.ParentNode.Nodes(i + 1)

    m_RadTreeFolderHierarchy.Nodes(0).Nodes.RemoveAt(i + 1)

    m_RadTreeFolderHierarchy.Nodes(0).Nodes.Insert(i, tempNode)

    Exit While

    End If

    i += 1

    End While

    End If

    End Select

    treeview_SaveChanges()

    Catch ex As Exception

  2. Veselin Vasilev
    Admin
    Veselin Vasilev avatar
    2992 posts

    Posted 16 Sep 2008 Link to this post

    Hello Bob,

    You can check this article that will show you how to upgrade the "classic" RadTreeView to RadTreeView for ASP.NET AJAX:
    Migrating from RadTreeView for ASP.NET to ASP.NET AJAX

    I hope this helps.

    Regards,
    Veskoni
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Bob
    Bob avatar
    55 posts
    Member since:
    Apr 2008

    Posted 16 Sep 2008 Link to this post

    Veskoni,

    The code compiles fine, but the move up and down do not work. No errors, just doesnt do anything.

     Any ideas?
  5. Simon
    Admin
    Simon avatar
    2281 posts

    Posted 19 Sep 2008 Link to this post

    Hello Bob,

    The "Moving a node up and down using a context menu" Code Library has been updated with a project for RadTreeView for ASP.NET AJAX.

    Please see the project for the ASP.NET AJAX implementation.

    Best wishes,
    Simon
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  6. Bob
    Bob avatar
    55 posts
    Member since:
    Apr 2008

    Posted 26 Sep 2008 Link to this post

    Here is a fix to the move down code

    Dim tempNode As New Telerik.Web.UI.RadTreeNode

    'This part is a bit nasty programming, first we remove the node before the node we want to move

    ' our nodeclicked is now automatically moving one place up

    tempNode = e.Node.ParentNode.Nodes(i - 1)

    'save a copy

    e.Node.ParentNode.Nodes(i - 1).Remove()

    'm_RadTreeFolderHierarchy.Nodes(0).Nodes.RemoveAt(i - 1) ' then delete that node

    'Then we insert the removed node one place under the moved node et voila

    e.Node.ParentNode.Nodes.Insert(i, tempNode)

    'm_RadTreeFolderHierarchy.Nodes(0).Nodes.Insert(i, tempNode)

Back to Top
UI for ASP.NET Ajax is Ready for VS 2017