Scroll to top after rebinding

4 posts, 1 answers
  1. Geejay
    Geejay avatar
    45 posts
    Member since:
    Feb 2007

    Posted 26 May Link to this post

    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

  2. Answer
    Ivan Danchev
    Admin
    Ivan Danchev avatar
    833 posts

    Posted 31 May Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Geejay
    Geejay avatar
    45 posts
    Member since:
    Feb 2007

    Posted 31 May in reply to Ivan Danchev Link to this post

    Thank you very much Ivan, works like a charm!
  5. Ivan Danchev
    Admin
    Ivan Danchev avatar
    833 posts

    Posted 01 Jun Link to this post

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