Paging in RadTreeView

7 posts, 0 answers
  1. Claudio
    Claudio avatar
    9 posts
    Member since:
    Feb 2009

    Posted 20 Sep 2010 Link to this post

    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
  2. Miro Miroslavov
    Admin
    Miro Miroslavov avatar
    588 posts

    Posted 23 Sep 2010 Link to this post

    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
  3. UI for WPF is Visual Studio 2017 Ready
  4. Joe
    Joe avatar
    5 posts
    Member since:
    Sep 2012

    Posted 13 Sep 2012 Link to this post

    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)?
  5. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 18 Sep 2012 Link to this post

    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.

  6. Joe
    Joe avatar
    5 posts
    Member since:
    Sep 2012

    Posted 18 Sep 2012 Link to this post

    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;
        }
  7. Joe
    Joe avatar
    5 posts
    Member since:
    Sep 2012

    Posted 18 Sep 2012 Link to this post

    Tina,

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

    -Joe
  8. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 20 Sep 2012 Link to this post

    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.

Back to Top
UI for WPF is Visual Studio 2017 Ready