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

Select items on page load

2 Answers 79 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Steven Mulkerrins
Top achievements
Rank 1
Steven Mulkerrins asked on 28 Apr 2010, 05:20 PM
Hi,

I have a Silverlight RadTreeView which is going to be used across a number of pages. I need to be able to persist which node is selected across page loads and refreshes. I am attempting to do this by storing info on the selected nodes in the Silverlight local storage, and then on load I am populating the treeview again and then trying to select the correct node.

I have seen code samples which loop through the items to find the correct one, and use the ItemContainerGenerator to get the RadTreeViewItem and then set isSelected etc. This approach doesn't work for me because I need to do this on page load, and the containers haven't been generated.

I have tried subscribing to the RadTreeView.ItemContainerGenerator.StatusChanged event and waiting for the status to be ContainersGenerated but this only seems to be for the containers at the top level. If the node I want to select is several nodes down then the container for it still has not been generated.

Ideally I think what I want to do is to hook into some event for all containers having been generated, or for data binding to be completed. Is there any such events, or is there any other approach that I can use ?

Thanks,
Steven.





2 Answers, 1 is accepted

Sort by
0
Vladislav
Telerik team
answered on 04 May 2010, 08:21 AM
Hello Steven Mulkerrins,

I am sorry for the delayed response.
Our suggestion is just to set the IsSelected to "true" of the RadTreeViewItem in the business object bound to the RadTreeView. With this approach - the desired element will be selected right after the binding is applied.

In order to accomplish this - you should use ContainerBindingCollection and this article demonstrating their usage.

Please, let us know if this approach works for you.

Kind regards,
Vladislav
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Steven Mulkerrins
Top achievements
Rank 1
answered on 04 May 2010, 08:36 AM
Thanks for the reply Vladislav, I had been been thinking of the problem over the weekend and that is the approcah that I was thinking of. I'll report if I run into any issues. Thanks.


Tags
TreeView
Asked by
Steven Mulkerrins
Top achievements
Rank 1
Answers by
Vladislav
Telerik team
Steven Mulkerrins
Top achievements
Rank 1
Share this question
or