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

Scroll into view not working upon loading of large tree

5 Answers 276 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
HDC
Top achievements
Rank 1
HDC asked on 15 Mar 2012, 01:19 PM
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


5 Answers, 1 is accepted

Sort by
0
Hristo
Telerik team
answered on 20 Mar 2012, 08:39 AM
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 >>
0
Accepted
Hristo
Telerik team
answered on 20 Mar 2012, 08:41 AM
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 >>
0
HDC
Top achievements
Rank 1
answered on 21 Mar 2012, 09:31 PM
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
0
Accepted
Petar Mladenov
Telerik team
answered on 26 Mar 2012, 04:58 PM
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 >>
0
HDC
Top achievements
Rank 1
answered on 26 Mar 2012, 05:21 PM
Perfectly!

Thanks Petar
Tags
TreeView
Asked by
HDC
Top achievements
Rank 1
Answers by
Hristo
Telerik team
HDC
Top achievements
Rank 1
Petar Mladenov
Telerik team
Share this question
or