Scroll into view not working upon loading of large tree

6 posts, 2 answers
  1. HDC
    HDC avatar
    214 posts
    Member since:
    Dec 2010

    Posted 15 Mar 2012 Link to this post

    Hi,

    I got a large tree, containing many nodes with child nodes several levels deep.Right after loading the nodes on the page, i can select the active node (using binding), but i don't succeed in bringing the selected node into view once the screen has been loaded.

    I have tried using the containergenerator events to bring the node into view but it doesn't work, even though the status flag indicates that the containers were generated. I also noticed that i can actually not get the container from any of the items that are not on the root level. So it seems to me that this event is thrown to early, since it appears that it is fired before ALL containers have been generated (this is probably the reason why i can't get it to work properly).

    BTW: If i start a timer from one of these containergenerator events and i wait just a second, then i can bring the node into view... so the code for bringing the item into view actually works, but i just cannot find any event that i can use to enable this scenario. I really don't want to resort to ugly hacks such as using a timer.

    Best Regards,

    Peter


  2. Hristo
    Admin
    Hristo avatar
    352 posts

    Posted 20 Mar 2012 Link to this post

    Hello,

    You could take a look at the following blog post describing the built-in bring into view functionality, hope it will be of help to you.
    Regarding the container generator event. They should be fired at the correct time, when the container is generated. But this moment could be too early for the item to be brought into view. Generally you need Loaded event of RadTreeView after the item has been fully created.

    Also, RadTreeView holds only first level items, which means you can get container only for the root items. In order to retrieve second level container you should use the container generator of its respective item's parent (a first level RadTreeViewItem). In addition, every RadTreeViewItem is lazy loaded. Which means, it will be generated the first time it is required (first time it should be shown into the view port).

    I totaly agree with you the timer workaround is an ugly hack and should not be used.

    Hope this helps. Please let us know if you need further assistance.

    Greetings,
    Hristo
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
  3. DevCraft banner
  4. Answer
    Hristo
    Admin
    Hristo avatar
    352 posts

    Posted 20 Mar 2012 Link to this post

    Hello,

    You could take a look at the following blog post describing the built-in bring into view functionality, hope it will be of help to you: http://blogs.telerik.com/xamlteam/posts/11-01-12/treeview-bringintoview.aspx 

    Regarding the container generator event. They should be fired at the correct time, when the container is generated. But this moment could be too early for the item to be brought into view. Generally you need Loaded event of RadTreeView after the item has been fully created.

    Also, RadTreeView holds only first level items, which means you can get container only for the root items. In order to retrieve second level container you should use the container generator of its respective item's parent (a first level RadTreeViewItem). In addition, every RadTreeViewItem is lazy loaded. Which means, it will be generated the first time it is required (first time it should be shown into the view port).

    I totaly agree with you the timer workaround is an ugly hack and should not be used.

    Hope this helps. Please let us know if you need further assistance.

    Greetings,
    Hristo
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
  5. HDC
    HDC avatar
    214 posts
    Member since:
    Dec 2010

    Posted 21 Mar 2012 Link to this post

    Hi Hristo,

    The method BringPathIntoView did do the trick.

    I do notice however that bring into view does not seem to work perfect... it "almost" brings the node into view. I still have to scroll down a little bit more (approximately 2 nodes) to really bring the node into view. I wonder what is causing this effect?

    Best Regards,

    Peter
  6. Answer
    Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 26 Mar 2012 Link to this post

    Hi Peter,

     Could you please try setting the BringIntoViewMode="HeaderAndItems" on the RadTreeView and let us know if this satisfies you? Thank you in advance.

    Greetings,
    Petar Mladenov
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
  7. HDC
    HDC avatar
    214 posts
    Member since:
    Dec 2010

    Posted 26 Mar 2012 Link to this post

    Perfectly!

    Thanks Petar
Back to Top
DevCraft banner