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

Scroll expanded node into view

3 Answers 46 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Richard
Top achievements
Rank 1
Richard asked on 29 Oct 2013, 11:50 PM
Hi,

I have seen this:

http://www.telerik.com/community/forums/aspnet-ajax/treeview/radtreeview-client-side-scrollintoview-for-selected-node-question.aspx

and this:

http://www.telerik.com/community/forums/aspnet-ajax/treeview/scrolling-to-last-expanded-node.aspx

However it doesnt achieve the results I need.

What is happening is that when I scroll all the way down the tree view and expand the last node (at the top level nodes) then it doesnt focus on the expanded children, I need to scroll down again to view the child nodes. What I want is for the childnodes to be shown upon expanding the parent node.

3 Answers, 1 is accepted

Sort by
0
Kate
Telerik team
answered on 01 Nov 2013, 02:32 PM
Hello Richard,

You can use the OnClientNodeExpanded or the OnClientNodeExpanding client side event, find the desired child node and call the scrollIntoVIew() property of the node as described here. Below is the sample code that you can use:
function ScrollNode()
{
   var tree = $find("<%= RadTreeView1.ClientID %>");
   var node = tree.findNodeByText("My Node");
   if(node)
   {
       node.scrollIntoView();
   }
}

Regards,
Kate
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
0
Richard
Top achievements
Rank 1
answered on 01 Nov 2013, 03:02 PM
Hi Kate,

If you look at the two links I provided one of them used the scrollintoview method which did not work for me.

I have tried it again and it does not work my end. Please try this your end too. Make sure the vertical scroll is available in your treeview and make sure the last node has children. Then scroll all the way down to the last node and expand it. Its children are not visible unless you scroll again.
0
Kate
Telerik team
answered on 06 Nov 2013, 02:16 PM
Hello Richard,

To be able to scroll to a specific node, this node needs to be visible. Therefore you will have to expand the parent node first. Attached to this post you can find my simplified runnable page that works as expected from my side. Try using the approach from the attached page.

Regards,
Kate
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Tags
TreeView
Asked by
Richard
Top achievements
Rank 1
Answers by
Kate
Telerik team
Richard
Top achievements
Rank 1
Share this question
or