RadTreeview bound to sitemap and handling unmapped pages

4 posts, 0 answers
  1. Joe
    Joe avatar
    13 posts
    Member since:
    Jul 2010

    Posted 11 Aug 2010 Link to this post

    Good Day,

    I am using a RadTreeview bound to a RadSiteMapDataSource configured as below.

    <telerik:RadSiteMapDataSource ID="SiteMapDataSource1" runat="server" ShowStartingNode="false" />
    <telerik:RadTreeView ID="SiteTree" runat="server" DataSourceID="SiteMapDataSource1" EnableViewState="true" SingleExpandPath="true">
        <ExpandAnimation Type="OutQuart" Duration="300" />
        <CollapseAnimation Type="OutQuint" Duration="200" />

    The sitemap's data represents a simple hierarchy of something like:

    There are other pages that exist beyond the child pages that are not represented in the sitemap, since they should not be selected from the nav menu.  The problem exists when navigating beyond the child page to an unmapped page.  The RadTreeview basically doesn't know which node was previously selected & therefore looses focus on the current selected node.  
    This seems to be a common problem with treeview controls since by default they don't persist using the session and is well documented in the wicked code article here: http://msdn.microsoft.com/en-us/magazine/cc163598.aspx in the section named SiteMapPaths and Unmapped Pages.

    I would like to configure the radtreeview to remember the currently selected node.  Basically when the user navigates off of the last mapped child page,  I'd like that last mapped child node to stay highlighted in the radtreeview.  

    I found a past forum post here: http://www.telerik.com/community/forums/aspnet/treeview/how-do-i-maintain-treeview-state-after-postback.aspx where it mentioned using the RetainScrollPosition attribute, but I cannot find any reference to it in the current release.  Based on that thread, it appeared that it did exactly what I was looking for...

    Any advise on how to accomplish this using the current radtreeview?

  2. Nikolay Tsenkov
    Nikolay Tsenkov avatar
    734 posts

    Posted 17 Aug 2010 Link to this post

    Hello Joe,

    The problem is that you navigate to a different url => (therefore) different page. In this case a new treeView is created and populated by the dataSource and so on. That's why the state doesn't persist.

    My advice for you is to keep the identification-data (e.g. value or text etc.) of the currently selected node in the session (preferably) or in a cookie and to reselect the node and expand the tree accordingly.

    Hope this will solve your problem and will not be too inconvenient to implement!

    Nikolay Tsenkov
    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. DevCraft R3 2016 release webinar banner
  4. Aarsh
    Aarsh avatar
    192 posts
    Member since:
    Jun 2012

    Posted 20 Sep 2012 Link to this post

    Nikolay, would you please post your sample code to do what you said ? Thanks !
  5. Bozhidar
    Bozhidar avatar
    1096 posts

    Posted 25 Sep 2012 Link to this post

    Hello Aarsh,

    You can use the method suggested in your other forum posts to achieve the functionality:
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Back to Top