Set focus to a node in RadTreeView

2 posts, 0 answers
  1. Sidhant
    Sidhant avatar
    4 posts
    Member since:
    May 2016

    Posted 17 May Link to this post

    I have a RadSplitter which house 2 vertical RadPanes both with scroll bars.

    The first pane has a RadTreeView inside a .Net User control and the second pane has an IFrame.

    I need to set focus on a particular node in the RadtreeView when the page is loaded so I don't have to scroll endlessly to reach that node when the page is first loaded.

    I tried using the following approach but it is not working :

    function scrollToNode(){
            var selected = $(".rtSelected");
            if(selected.length > 0){
            var TotalScrollNeeded = selected.offset().top
                - $("#radTree").offset().top
                + $("#radTree").scrollTop();
            $("#radTree").animate({ scrollTop: TotalScrollNeeded }, 1000);
            }

  2. Ivan Danchev
    Admin
    Ivan Danchev avatar
    829 posts

    Posted 19 May Link to this post

    Hello Sidhant,

    You can try the following approach to scroll to the initially selected TreeView node, which uses the RadTreeView and RadTreeNode client-side methods:
    function pageLoad() {
        scrollToNode();   
    }
     
    function scrollToNode() {
        var tree = $find('<%= RadTreeView1.ClientID %>');
        var node = tree.get_selectedNode();
     
        if (node) {
            node.scrollIntoView();
        }
    }


    Regards,
    Ivan Danchev
    Telerik
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top