Community & Support

Scrolling to the selected node

Article Info

Rating: 4

HOW-TO
Scroll to a node

SOLUTION

If you need to scroll to a certain node you can use a simple JS code to do so. The example below shows how to scroll the the selected node upon page_load:

<script language="javascript"
    function pageLoad() 
    { 
        var tree = $find("<%=RadTreeView1.ClientID %>"); 
        var selectedNode = tree.get_selectedNode();                 
        if (selectedNode) 
        {  
            selectedNode.scrollIntoView(); 
        } 
    }   
</script> 




<body onload="setTimeout('ScrollToSelectedNode()', 20);"
    ... 
    <script language="javascript"
      function ScrollToSelectedNode() 
      { 
           var tree = <%=RadTreeView1.ClientID %> 
           var selectedNode = tree.SelectedNode; 
           if (selectedNode != null
           {  
              selectedNode.ScrollIntoView(); 
           } 
      }   
    </script> 
    ... 
</body> 
         
         


 
 

Comments

  • Kim Mogensen , Nov 7, 2006

    Above works flawless in my application... Though the code should look like something like this:

  • Above is taken from the downloadable sample. If the javascript section is not placed within the form tag the reference to the the RadTree is void.

If you'd like to comment on this KB article, please, send us a Support Ticket.
Thank you!

Please Sign In to rate this article.