This is a migrated thread and some comments may be shown as answers.

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

4 Answers 45 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Bob
Top achievements
Rank 1
Bob asked on 16 Sep 2008, 01:34 PM
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

4 Answers, 1 is accepted

Sort by
0
Veselin Vasilev
Telerik team
answered on 16 Sep 2008, 03:20 PM
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.
0
Bob
Top achievements
Rank 1
answered on 16 Sep 2008, 03:32 PM
Veskoni,

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

 Any ideas?
0
Simon
Telerik team
answered on 19 Sep 2008, 11:48 AM
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.
0
Bob
Top achievements
Rank 1
answered on 26 Sep 2008, 06:18 PM
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)

Tags
TreeView
Asked by
Bob
Top achievements
Rank 1
Answers by
Veselin Vasilev
Telerik team
Bob
Top achievements
Rank 1
Simon
Telerik team
Share this question
or