Skip Navigation LinksHome / Community & Support / Code Library / ASP.NET AJAX > TreeView > Moving a node up and down using a context menu

Moving a node up and down using a context menu

Feed from this thread
  • Posted on Jun 13, 2006 (permalink)

     

    Requirements

    To convert code from posted project(s) Telerik online converter
    RadTreeView version

    5.3

    or

    RadTreeView for ASP.NET AJAX

    .NET version

    1.1 or 2.0+

    Visual Studio version

    2003/2005/2008

    programming language

    VB.NET

    browser support

    all browsers supported by RadTreeView




    Hi all,

    This demo project shows you how you can move a node up and down using a context menu. The demo doesn't use a database or a XML file. So it's pure code. The way the demo moves the nodes is not really professional but it'll give you an idea.

    In my own project I used a database, this is simpler and more professional. If you have any questions about this demo, or how to do it with a database, mail me at stan0611@hotmail.com

    Happy coding :)

    Edit (by Telerik Admin): A project for RadTreeView for ASP.NET AJAX has been added to the Code Library.

    Reply

  • Vassil Petev Vassil Petev admin's avatar

    Posted on Jun 13, 2006 (permalink)


    Hello Stan,

    Thank you for posting this demo application in our code library section. I replaced the r.a.d.treeview DLL with the latest trial version and applied a style to the context menu, so that it looks nice :)

    As appreciation for your involvement I have updated your telerik points.  


    Sincerely yours,
    Rob
    the telerik team

    Reply

  • Posted on Jun 21, 2007 (permalink)

    hi, i'm new to asp.net and I wasn't sure why the files are not opening on my Visual Studio?

    Reply

  • Poul Henningsen Master avatar

    Posted on Jun 22, 2007 (permalink)

    Hi chocolate,

    Maybe you're using VS2005. As it is stated in the Requirements table above this project is for VS2003.

    Poul

    Reply

  • Bob avatar

    Posted on Sep 22, 2008 (permalink)

    I have modified the tests to be compatable with MOSS webpart.  Specifically, I test UniqueID instead of value (which was not returning anything).


    Case
    "move up"

    ls_MsgTxt =

    "Move Up Start" '& e.Node.UniqueID.ToString & "' / '" & e.Node.ParentNode.Nodes(0).UniqueID.ToString & "'"

    'statusLabel.Text = ls_MsgTxt

    '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.UniqueID = e.Node.ParentNode.Nodes(0).UniqueID Then

    ls_MsgTxt =

    "Move Up . " ' & e.Node.ParentNode.Nodes.Count.ToString

    'statusLabel.Text = ls_MsgTxt

    Dim i As Integer = 0

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

    ls_MsgTxt =

    "Move Up .. " '& i.ToString & " / " & e.Node.ParentNode.Nodes.Count.ToString

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

    ls_MsgTxt =

    "Moved Up" '& e.Node.UniqueID.ToString & " / " & e.Node.ParentNode.Nodes(i).UniqueID.ToString

    '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.UniqueID = e.Node.ParentNode.Nodes(e.Node.ParentNode.Nodes.Count - 1).UniqueID Then

    Dim i As Integer = 0

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

    If e.Node.UniqueID = e.Node.ParentNode.Nodes(i).UniqueID 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

    Reply

  • Karthik Kantharaj Intermediate avatar

    Posted on Aug 9, 2011 (permalink)

    Hi Stan

    Can i get the same in C#?

    I am using VS 2010
    Telerik 2011.2.726.35

    Thanks
    Karthik.K

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Code Library / ASP.NET AJAX > TreeView > Moving a node up and down using a context menu