Moving a node up and down using a context menu

6 posts, 0 answers
  1. stan0611
    stan0611 avatar
    33 posts
    Member since:
    Jun 2006

    Posted 13 Jun 2006 Link to this post

     

    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.
  2. Vassil Petev
    Admin
    Vassil Petev avatar
    1765 posts

    Posted 13 Jun 2006 Link to this post


    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
  3. chocolate
    chocolate avatar
    1 posts
    Member since:
    Jun 2007

    Posted 21 Jun 2007 Link to this post

    hi, i'm new to asp.net and I wasn't sure why the files are not opening on my Visual Studio?
  4. Poul Henningsen
    Poul Henningsen avatar
    194 posts
    Member since:
    May 2006

    Posted 22 Jun 2007 Link to this post

    Hi chocolate,

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

    Poul
  5. Bob
    Bob avatar
    55 posts
    Member since:
    Apr 2008

    Posted 22 Sep 2008 Link to this post

    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

  6. Karthik Kantharaj
    Karthik Kantharaj avatar
    101 posts
    Member since:
    Mar 2010

    Posted 09 Aug 2011 Link to this post

    Hi Stan

    Can i get the same in C#?

    I am using VS 2010
    Telerik 2011.2.726.35

    Thanks
    Karthik.K
Back to Top