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

A 'new' type of binding problem?

2 Answers 42 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Stuart Hemming
Top achievements
Rank 2
Stuart Hemming asked on 18 Sep 2009, 10:37 AM
We're using a treeview to provide a navigation tool.

At a certain level we want to display some hierarchical data.

Can any one think of a straightforward way of adding hierarchical data to a node in an existing tree without destroying the existing nodes?

--
Stuart

2 Answers, 1 is accepted

Sort by
0
Accepted
Atanas Korchev
Telerik team
answered on 18 Sep 2009, 11:51 AM
Hello Stuart Hemming,

RadTreeView does not provide bult-in support for this scenario. However I can propose a workaround:

  1. Creating a temporary RadTreeView object and bind the data to it
  2. Traverse all root nodes of the temporary treeview and add them to the existing node in the original treeview

Regards,
Albert,
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Stuart Hemming
Top achievements
Rank 2
answered on 18 Sep 2009, 03:00 PM
Albert,

Cracking! I didn't think I'd be able to just move nodes like that.

I added an extension for the RadTreeNode class like this...
namespace UEAPL.Shared.Extensions 
    public static class RadTreeNodeExtensions 
    { 
        public static void AddHierarchy(this RadTreeNode node, object DataSource, string DataTextField, string DataValueField, string DataFieldID, string DataFieldParentID) 
        { 
            RadTreeView t = new RadTreeView(); 
 
            t.DataTextField = DataTextField; 
            t.DataValueField = DataValueField; 
            t.DataFieldID = DataFieldID; 
            t.DataFieldParentID = DataFieldParentID; 
            t.DataSource = DataSource; 
            t.DataBind(); 
 
            while (t.Nodes.Count > 0) 
            { 
                node.Nodes.Add(t.Nodes[0]); 
            } 
        } 
    } 
 


Tags
TreeView
Asked by
Stuart Hemming
Top achievements
Rank 2
Answers by
Atanas Korchev
Telerik team
Stuart Hemming
Top achievements
Rank 2
Share this question
or