Expand all root items

7 posts, 0 answers
  1. hwsoderlund
    hwsoderlund avatar
    419 posts
    Member since:
    Aug 2006

    Posted 23 Jul 2010 Link to this post

    Hi, I need to make sure that all root nodes are expanded on initial load. With the CTP version of RadTreeListView (based on RadTreeView), I used the following:

    void HierarchyTree_ItemPrepared(object sender, RadTreeViewItemPreparedEventArgs e)
    {
        RadTreeViewItem item = e.PreparedItem;
     
        //Root items should be expanded on initial load
        if (item.IsRootItem)
            item.IsExpanded = true;
    }


    What is the simplest equivalent in the current version of RadTreeListView?

    /Henrik
  2. Yavor Georgiev
    Admin
    Yavor Georgiev avatar
    982 posts

    Posted 23 Jul 2010 Link to this post

    Hi hwsoderlund,

     You can handle the DataLoaded event of RadTreeListView like so:

    void treeListView_DataLoaded(object sender, EventArgs e)
    {
        var source = this.treeListView.ItemsSource as ICollection;
        if (this.treeListView.Items.Count == source.Count)
        {
            foreach (var item in source)
            {
                this.treeListView.ExpandHierarchyItem(item);
            }
        }
        else if (this.treeListView.Items.Count > source.Count)
        {
            this.treeListView.DataLoaded -= this.treeListView_DataLoaded;
        }
    }

    All the best,
    Yavor Georgiev
    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. DevCraft banner
  4. Thomas Whittaker
    Thomas Whittaker avatar
    34 posts
    Member since:
    Sep 2009

    Posted 05 Aug 2010 Link to this post

    When I try to call ExpandHeirarchyItem in response to the DataLoaded event, I get an error 'Value does not fall in expected range', seemingly because there are no items in the treeListView.Items collection yet.  Am I missing something?
  5. Yavor Georgiev
    Admin
    Yavor Georgiev avatar
    982 posts

    Posted 09 Aug 2010 Link to this post

    Hi Thomas Whittaker,

     Could you please post some code snippets so that I can learn a bit more about your scenario? A sample project would be best, though. If you are willing to send us a sample application, please open a support ticket. Either way, I'll try to help you as quickly as possible.

    Sincerely yours,
    Yavor Georgiev
    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
  6. Thomas Whittaker
    Thomas Whittaker avatar
    34 posts
    Member since:
    Sep 2009

    Posted 10 Aug 2010 Link to this post

    I am not exactly sure what I was doing wrong.  When I went back later and put my ExpandHierarchyItem call in the RowLoaded event handler, it worked.  I haven't gone back to try the DataLoaded event handler because RowLoaded was what I wanted anyway.
  7. Ivano
    Ivano avatar
    39 posts
    Member since:
    Feb 2009

    Posted 03 Jun 2011 Link to this post

    Hi

    your example works fine but when I set RadTreeListView.ItemsSource again DataLoaded event is no more fired; how shuold I expand all roots any time I set ItemsSource?

    Thanks
  8. Richard M
    Richard M avatar
    15 posts
    Member since:
    Feb 2010

    Posted 27 Sep 2011 Link to this post

    Reattach the event before you set the item source
Back to Top
DevCraft banner