Select items on page load

3 posts, 0 answers
  1. Steven Mulkerrins
    Steven Mulkerrins avatar
    2 posts
    Member since:
    Apr 2010

    Posted 28 Apr 2010 Link to this post


    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 ?


  2. Vladislav
    Vladislav avatar
    277 posts

    Posted 04 May 2010 Link to this post

    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,
    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.
  3. Steven Mulkerrins
    Steven Mulkerrins avatar
    2 posts
    Member since:
    Apr 2010

    Posted 04 May 2010 Link to this post

    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.

Back to Top