RadTreeView, How to set the focus to a selected node on postbacks?

2 posts, 0 answers
  1. Thayu
    Thayu avatar
    1 posts
    Member since:
    Jul 2010

    Posted 19 Apr 2011 Link to this post


    We are dynamically creating a Menu using RadTreeView control and each node is binded with .aspx page. When a node is clicked, the whole page postbacks and redirects to the assigned .aspx page and the RadTreeView control(Menu) will be recreated. As the page postbacks, the selected node losts its focus and all the nodes are getting collapsed.

    As per our requirement, We need to set the focus on the selected node and its parent node to be expanded, even if the page postbacks. Please help us on this.

    We tried getting the selected node value on RadTreeView_NodeClick event and this event is not firing consistantly.

    FYI, we are binding the RadTreeView control using LINQ on Page_Load event and below is the code for the same.


    rtvMenu.DataTextField =





    rtvMenu.DataValueField =





    rtvMenu.DataFieldID =





    rtvMenu.DataFieldParentID =





    rtvMenu.DataNavigateUrlField =





    rtvMenu.DataSource = v_Menu;




  2. Nikolay Tsenkov
    Nikolay Tsenkov avatar
    734 posts

    Posted 21 Apr 2011 Link to this post

    Hi Thayu,

    The fact every node is associated to a page, means that by being on a certain page you should be able to determine the clicked node using the url of the page - you can get all nodes and iterate through them searching for a specific navigateUrl (to get the nodes - tree.get_allNodes(), to check for the same url - node.get_navigateUrl()). Then having the node, you only need to iterate through the parent's expanding them (use the level of the node as a limiter for the for-loop - for (var i = 0; i < node.get_level(); i++)).

    Another way to achieve this is to save the clicked node in a cookie or the Session. You can check the last post at this thread, how you can implement the cookie solution: http://www.telerik.com/community/forums/aspnet-ajax/treeview/scrollintoview-with-ajaxified-control-doesn-t-work.aspx

    Nikolay Tsenkov
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Back to Top