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

RadTreeNode.ParentNode is Read Only

2 Answers 131 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Eric
Top achievements
Rank 1
Eric asked on 22 Apr 2011, 12:05 AM

Hi,
Can you please correct me where I'm wrong and educate me where I need it here -  I've just discovered that the
Parent Node property of the RadTreeNode object is read-only and a couple things come to mind.

1.
I discovered this after writing some recursive sql to retrieve an entire branch (all descendants, all levels) of a root node.  I populate my treeview via LoadOnDemand->WebMethod approach and in certain scenarios I want the option to retrieve either one level deep or the entire branch. I intended to populate the parentnode values as I built the tree but now see I cannot do that.
Do I have any options?

2.
It also seems that in a LoadOnDemand scenario, in order to re-establish your CurrentNode positioning (Selected, Focused, and In View) after a page reload you would have to (if Current Node was not a root node) load down the branch at
least to the level of the Current Node in order to establish positioning. Am I missing something? Is there a standard or best-practice approach to accomplishing this?

Why is Parent Node read-only? If the source code is available is it reasonable
to consider my own version where parent node is not read-only?

Thanks!
Eric

2 Answers, 1 is accepted

Sort by
0
Nikolay Tsenkov
Telerik team
answered on 22 Apr 2011, 03:14 PM
Hello Eric,

RadTreeView support many types of Data Sources and Data Binding. Here is a nice article that lists all supported types of Data Binding: http://www.telerik.com/help/aspnet-ajax/treeview-data-binding-overview.html

About the expanded state of the TreeView on reload of the page:
 - My suggestion is not to use Load On Demand if you are going to need the page to save the expansion of RadTreeView. Perhaps you are facing a scenario with RadTreeView on a MasterPage with content pages assigned as NavigateUrls to the nodes of the TreeView. And if you navigate to a certain page, you need to be able to expand the TreeView accordingly. If your case is similar (or same), and if there are as much as hundreds not thousands of nodes, the performance should not be harmed too badly.

About the ParentNode being Read-only:
 - We try to enforce good practices where possible and for that reason the creation and adding of a node as a child to another node happens strictly and only in a single way - instantiate the node and add it to the nodes collection. The ParentNode is added only for users convenience when navigation through the tree-structure is required (especially top-down - from leave-nodes to root).


Regards,
Nikolay Tsenkov
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

0
Darren
Top achievements
Rank 1
answered on 05 Oct 2017, 11:11 PM

I want to select the node 

This following code requires a id to search for but I can not assign an Id to the RadTreeNode because it is ReadOnly.

Please help me. I want to be able to have certain node opened by entering parameters but I do not know how to select the nodes.

var node = rootNodes.FindNodeByValue(linkID);

This code fails too because it is Readonly

AlbumRTV.SelectedNode = AlbumRTV.Nodes[0]; 

Tags
TreeView
Asked by
Eric
Top achievements
Rank 1
Answers by
Nikolay Tsenkov
Telerik team
Darren
Top achievements
Rank 1
Share this question
or