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

Scroll to top after rebinding

3 Answers 60 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Geejay
Top achievements
Rank 1
Geejay asked on 26 May 2016, 07:19 AM

Hello Telerik,

I have a treeview with many nodes with checkboxes. When I check the very last node, this is saved in a database and I rebind the treeview. After that, the checked nodes appear at first at the top at the treeview, the unchecked nodes follow underneath. So far no problem. But after rebinding I want the treeview to scroll up to the top. The scrollbar however stays at the bottom and the selected node(s) stays out of sight. I managed to get arround that by, after rebinding the treeview, setting focus on the first node and use examples on your forum to scroll to the top of the treeview. But doing so, the first node is selected and I don't want that, it's an 'ugly' solution. Is there a way to do this in a more elegant way?

Thanks,

Geert

3 Answers, 1 is accepted

Sort by
0
Accepted
Ivan Danchev
Telerik team
answered on 31 May 2016, 06:59 AM
Hello Geert,

You can scroll to the first TreeView node by calling the node's scrollIntoView() client-side method:
var tree = $find("<%= RadTreeView1.ClientID %>");
var node = tree.get_nodes().getNode(0);
if (node) {
    node.scrollIntoView();
}

Calling this method only scrolls to the node and does not select or check it. This and other methods of the different TreeView objects you can find in the corresponding section of the documentation.

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.
0
Geejay
Top achievements
Rank 1
answered on 31 May 2016, 10:57 AM
Thank you very much Ivan, works like a charm!
0
Ivan Danchev
Telerik team
answered on 01 Jun 2016, 02:57 PM
Hello Geert,

I am glad the suggested way of scrolling through using the scrollIntoView() method helped you achieve the desired behavior.

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
Geejay
Top achievements
Rank 1
Answers by
Ivan Danchev
Telerik team
Geejay
Top achievements
Rank 1
Share this question
or