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

[Solved] RadTreeView GetItemByPath

5 Answers 234 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Rob
Top achievements
Rank 1
Rob asked on 22 Jul 2008, 08:10 PM

I am currently using the RadTreeView to organize a list of unrelated items. As an example my top level consists of Projects and Contacts. Under the Projects node I have Owned, Monitored, and Participant nodes with LoadOnDemand enabled. Under each of those nodes I have project data nodes. When one of these nodes is selected an editable project detail form is diplayed. I would like to do the following:

1. Mark the "context" of the currently selected item. For example, if a project is selected I would identify the Projects node as the context node.
2. Reload the tree view
3. Expand the nodes under the context node.

There are a few scenarios where I would like to do this:

  • I have just finished editing an item in the tree. For example, I may have changed the title displayed in the tree.
  • I have just deleted an item from the tree
  • I have just added an item to the tree

My first inclination was to use the FullPath property to identify my context node and then use GetItemByPath to retrieve that node after reloading the tree. I would then load and expand the context node's subtree. I have been encountering some difficulty with FulPath though. It appears that the FullPath property throws an exception for any node that has children that have not yet been loaded. Is this a bug or by design? Am I going about this the wrong way? Do you have any advice or sample code for this type of thing?

Thanks
Rob

5 Answers, 1 is accepted

Sort by
0
Valentin.Stoychev
Telerik team
answered on 24 Jul 2008, 03:43 PM
Hello Rob,

I already wrote you in anothe ticket, but just want to clarify that the GetItemByPath method is not giving an excpetion - it just returns null, because the item you are looking for is still not generated.  Once again - see how the ItemContainerGenerator is used in order to make your scenario working.

Let us know if you have problems implementing the logic. We will write a KB article soon about how to traverse the RadTreeView.

Sincerely yours,
Valentin.Stoychev
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Josef Rogovsky
Top achievements
Rank 2
answered on 01 Sep 2009, 12:21 PM
Is there an update on this?
0
Miroslav
Telerik team
answered on 01 Sep 2009, 04:51 PM
Hi Josef Rogovsky,

Yes, there are now two methods that will expand to an item.

The GetItemByPath(path) method will expand to an item synchronously and it will return this item. The GetItemByPath method should not return null if the item is reachable.

The ExpandItemByPath(path) will expand to an item asynchronously. This is why it does not return the item.

Greetings,
Miroslav
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
Josef Rogovsky
Top achievements
Rank 2
answered on 14 Sep 2009, 02:55 PM
Hi Miroslav,

What I'm hoping to see soon is a KB article on how to traverse the tree. I've recently posted a support ticket for basically this request because I need to be able to find and select nodes by value where I have no idea of the path.
0
Miroslav
Telerik team
answered on 17 Sep 2009, 12:27 PM
Hi Josef,

Yes, due to the lazy manner in which Silverlight and WPF controls are loaded, it is not trivial to select an item by its value (and not its path).

Almost certainly this will not be a built-in feature of the TreeView and it has to be done in the underlying ViewModel.

The problem is that the TreeView has no idea of the existence or value of items in the branches that have not been expanded yet. With the Q3 release the TreeView will be virtualized, which means that only the visible 20-30 item containers will be present - this will improve the performance but it will mean that increasingly containers will not be available. Then, if there are no containers, there is no reasonable way to get the subitems of the root-level items.

Thank you for the reminder, I will prepare an example with the different cases of getting an item.

I will reply to your other thread as well with more concrete ideas for your scenario.

Best wishes,
Miroslav
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.
Tags
General Discussions
Asked by
Rob
Top achievements
Rank 1
Answers by
Valentin.Stoychev
Telerik team
Josef Rogovsky
Top achievements
Rank 2
Miroslav
Telerik team
Share this question
or