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

Paging in RadTreeView

6 Answers 118 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Claudio
Top achievements
Rank 1
Claudio asked on 20 Sep 2010, 11:09 AM
Hi,
im trying to add 1000 nodes at the root level using load on demand functionality.
Is possible to enable paging on the tree view in order to load only 50 nodes at time ??

Best Regards
Claudio

6 Answers, 1 is accepted

Sort by
0
Miro Miroslavov
Telerik team
answered on 23 Sep 2010, 11:27 AM
Hi Claudio,

 In my opinion paging is not a good option for a TreeView. It is also hard to achieve - we don't have such example or a way to do it. You'd better use the so called virtualization technique (check out the example) - can download for example all the 1000 ids from the server. Then start loading all the needed information for-each Id on the background, so when it is available - the binding will do the rest. Other approach could be to load a node when the actual container is created (realized)  due to the virtualization.
Please let me know if we can be of further help regarding any approach you've choose.

Kind regards,
Miro Miroslavov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Joe
Top achievements
Rank 1
answered on 13 Sep 2012, 05:23 PM
We would like to same functionality.  Of course we are talking thousands of nodes, and the node retrieval (from the datasource) can be time consuming.  We do know the total count of the items, but would like to only load a certain page size.  Is it possible to somehow set an observable collection to given size (with nulls perhaps)?
0
Tina Stancheva
Telerik team
answered on 18 Sep 2012, 03:09 PM
Hi Joe,

The RadTreeView doesn't have a built-in paging functionality. Instead it support UIVirtualization so that only the items in the viewport are generated (realized), as well as load-on-demand - in order to allow you to load the children items on demand - after expanding a parent item. Both of these features are designed to optimize the performance of the RadTreeView as much as possible and you can check out the demo Miro mentioned in the previous reply (http://demos.telerik.com/silverlight/#TreeView/Performance) where a million items are generated as the RadTreeView.ItemsSource collection.

However, if your goal is to use paging, then you'll have to use it in the collection you're loading. Basically the RadTreeView displays the entire length of its ItemsSource collection (although in virtualized mode, in every single moment it realizes only the items in the viewport area). So if you'd like to display only a number of items from your original collection, you'll have to create a sample collection containing only the desired number of items and set that sample collection as the RadTreeView.ItemsSource.

Regards,
Tina Stancheva
the Telerik team

Time to cast your vote for Telerik! Tell DevPro Connections and Windows IT Pro why Telerik is your choice. Telerik is nominated in a total of 25 categories.

0
Joe
Top achievements
Rank 1
answered on 19 Sep 2012, 02:19 AM
Tina,

For the most part, I have this working as you suggested.

"So if you'd like to display only a number of items from your original collection, you'll have to create a sample collection containing only the desired number of items and set that sample collection as the RadTreeView.ItemsSource."

I implemented your suggestion, I created a VirtualCollection (derived from IList and set the total count, populating each item when requested).  Works fine.

During the LoadOnDemand event, I create my virtual collection and then set the radTreeviewItem.ItemsSource=mycollection.  This works fine until I collapse the parent node and re-expand.  For example, if I have say three levels deep:
 
Person
    Child
        Dog
 
then collapse the Person node and expand it again, the Child node does appear, but there is no expanding button, and therefore no Dog node.  It's almost like I need to reset the ItemsSource.  I tried the below code with an ObservableCollection<Person> (instead of virtual), and it exhibited the same behavior.  If I don't include a binding statement in my .xaml for the child nodes, it DOES NOT work.  If I add a binding statement (Binding Path=Children) for example, it does work.  Any suggestions????

 

private void radTreeView1_LoadOnDemand (object sender, Telerik.Windows.RadRoutedEventArgs e)
    {
    RadTreeViewItem radTreeViewItem = e.OriginalSource as RadTreeViewItem;
 
    //service that will return viewmodels
    var service = new PersonService (10/*count*/);
 
    //create the virtual collection and set the ItemsSource
    radTreeViewItem.ItemsSource = new VirtualCollection<Person> (service, 2/*page size*/);
 
    //done loading
    radTreeViewItem.IsLoadOnDemandEnabled = false;
    }
0
Joe
Top achievements
Rank 1
answered on 19 Sep 2012, 04:19 AM
Tina,

Sorry, I may have this working.  I'll let you know my status :-)

-Joe
0
Tina Stancheva
Telerik team
answered on 20 Sep 2012, 01:41 PM
Hi Joe,

How is your solution going? Did you manage to get it working? Let us know if you haven't so that we can assist you implementing your requirements.

Regards,
Tina Stancheva
the Telerik team

Time to cast your vote for Telerik! Tell DevPro Connections and Windows IT Pro why Telerik is your choice. Telerik is nominated in a total of 25 categories.

Tags
TreeView
Asked by
Claudio
Top achievements
Rank 1
Answers by
Miro Miroslavov
Telerik team
Joe
Top achievements
Rank 1
Tina Stancheva
Telerik team
Share this question
or