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

Set focus to a node in RadTreeView

1 Answer 361 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Sidhant
Top achievements
Rank 1
Sidhant asked on 17 May 2016, 07:29 AM

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);
        }

1 Answer, 1 is accepted

Sort by
0
Ivan Danchev
Telerik team
answered on 19 May 2016, 02:42 PM
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.
Tags
TreeView
Asked by
Sidhant
Top achievements
Rank 1
Answers by
Ivan Danchev
Telerik team
Share this question
or