Scroll expanded node into view

4 posts, 0 answers
  1. Richard
    Richard avatar
    15 posts
    Member since:
    May 2012

    Posted 29 Oct 2013 Link to this post

    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.
  2. Kate
    Admin
    Kate avatar
    1898 posts

    Posted 01 Nov 2013 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Richard
    Richard avatar
    15 posts
    Member since:
    May 2012

    Posted 01 Nov 2013 Link to this post

    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.
  5. Kate
    Admin
    Kate avatar
    1898 posts

    Posted 06 Nov 2013 Link to this post

    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.
Back to Top