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

RadTreeview bound to sitemap and handling unmapped pages

3 Answers 47 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Joe
Top achievements
Rank 1
Joe asked on 11 Aug 2010, 09:28 PM
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" />
</telerik:RadTreeView>

The sitemap's data represents a simple hierarchy of something like:
parent1---
--child1
--child2
parent2---
---child1
---child2

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?

3 Answers, 1 is accepted

Sort by
0
Nikolay Tsenkov
Telerik team
answered on 17 Aug 2010, 09:48 AM
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!


Regards,
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
0
Aarsh
Top achievements
Rank 1
answered on 20 Sep 2012, 05:55 PM
Nikolay, would you please post your sample code to do what you said ? Thanks !
0
Bozhidar
Telerik team
answered on 25 Sep 2012, 09:57 AM
Hello Aarsh,

You can use the method suggested in your other forum posts to achieve the functionality:
http://www.telerik.com/community/forums/aspnet-ajax/treeview/rad-tree-view-reloading-after-a-postback.aspx
http://www.telerik.com/community/forums/aspnet-ajax/treeview/609454-rad-tree-view-reloading-after-a-postback.aspx 
 
Greetings,
Bozhidar
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.
Tags
TreeView
Asked by
Joe
Top achievements
Rank 1
Answers by
Nikolay Tsenkov
Telerik team
Aarsh
Top achievements
Rank 1
Bozhidar
Telerik team
Share this question
or