Automatically expand all nodes in RadTreeListView v2010.2.714 by default

15 posts, 0 answers
  1. Rami Abughazaleh
    Rami Abughazaleh avatar
    27 posts
    Member since:
    Feb 2010

    Posted 16 Jul 2010 Link to this post

    RadControls for Silverlight 4 v2010.2.714

    In the previous version (RadControls for Silverlight 4 v2010.1.603) I was able to use the following syntax to automatically expand all nodes by default:

    <telerikNavigation:RadTreeListView>
            <telerikNavigation:RadTreeListView.ItemContainerStyle>
                <Style TargetType="telerikNavigation:RadTreeListViewItem">
                    <Setter Property="IsExpanded" Value="True" />
                </Style>
            </telerikNavigation:RadTreeListView.ItemContainerStyle>
        </telerikNavigation:RadTreeListView>

    As indicated here:
    http://www.telerik.com/community/forums/silverlight/treelist/when-to-call-expandall.aspx

    However, I have tried similar syntax but it is not working as expected.
    <telerik:RadTreeListView.ItemContainerStyle>
      <Style TargetType="telerik:GridViewRow">
        <Setter Property="IsExpanded" Value="True" />
      </Style>
    </telerik:RadTreeListView.ItemContainerStyle>

    Is this feature not available with the latest release (RadControls for Silverlight 4 v2010.2.714)?

    Thank you.
  2. Mike
    Mike avatar
    17 posts
    Member since:
    Jul 2010

    Posted 18 Jul 2010 Link to this post

    I was able to resolve this issue by calling the ExpandAllHierarchyItems() method on the RadTreeListView.
  3. DevCraft banner
  4. Stephen
    Stephen avatar
    14 posts
    Member since:
    Jul 2010

    Posted 21 Jul 2010 Link to this post

    I would like to be able to do this in xaml, without having the code-behind. Is it possible with the current version?

     Cheers,
     Steve
  5. Andy Fry
    Andy Fry avatar
    9 posts
    Member since:
    Nov 2009

    Posted 21 Jul 2010 Link to this post

    I am also interested in how you bind the IsExpanded property to a property on the objects that I have the TreeListView bound to.
  6. Rami Abughazaleh
    Rami Abughazaleh avatar
    27 posts
    Member since:
    Feb 2010

    Posted 21 Jul 2010 Link to this post

    I'm thinking you can use the ContainerBindingCollection.

    http://www.telerik.com/support/kb/silverlight/treeview/radtreeview-and-hierarchicaldatatemplate.aspx

    http://www.telerik.com/community/forums/silverlight/tabcontrol/setting-isselected-via-databinding-at-runtime.aspx
  7. Stefan Dobrev
    Admin
    Stefan Dobrev avatar
    790 posts

    Posted 23 Jul 2010 Link to this post

    Hello all,

    Container bindings are not yet supported in the new version of RadTreeListView. What you can do currently is to use RowLoaded and RowUnloaded events. In the loaded event you will bind specific row properties to the respective properties of your data items. In the unloaded event you can unbind them - using ClearValue(...) method.

    Best wishes,
    Stefan Dobrev
    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
  8. David Schnebly
    David Schnebly avatar
    1 posts
    Member since:
    Jul 2009

    Posted 27 Jul 2010 Link to this post

    Is there an estimated time when container bindings will be working for the RadTreeListView?
  9. Stefan Dobrev
    Admin
    Stefan Dobrev avatar
    790 posts

    Posted 30 Jul 2010 Link to this post

    Hello David,

    We did not have an estimate when the container bindings will be implemented for RadTreeListView. Can you share more details about your scenario? Why is the RowLoaded event not sufficient for your case?

    Greetings,
    Stefan Dobrev
    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
  10. Tim Tos
    Tim Tos avatar
    36 posts
    Member since:
    Apr 2010

    Posted 31 Jul 2010 Link to this post

    Hello Stefan,

    I also need this functionality although I don't want to expand all nodes by default.
    I want to expand a node according to the ViewModel! I used the XAML-Code below and it was working very well!
    Now - with Q2 - I don't know how to solve this elegant and at least for my scenario it is very ugly to use the event you spoke about!
    My XAML-Code:

    <my:RadTreeListView.ItemContainerStyle>
        <Style TargetType="local:TableItemViewModel">
         <Setter Property="util:SetterValueBindingHelper.PropertyBinding">
          <Setter.Value>
           <util:SetterValueBindingHelper
                                    Property="IsExpanded"
                                    Binding="{Binding IsExpanded}"/>
          </Setter.Value>
         </Setter>
        </Style>
    </my:RadTreeListView.ItemContainerStyle>

    Any ideas?
    Thanks,
    Tim.
  11. Stefan Dobrev
    Admin
    Stefan Dobrev avatar
    790 posts

    Posted 04 Aug 2010 Link to this post

    Hello Tim,

    You should use RowStyle property for your scenario.

    Kind regards,
    Stefan Dobrev
    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
  12. Tim Tos
    Tim Tos avatar
    36 posts
    Member since:
    Apr 2010

    Posted 05 Aug 2010 Link to this post

    Hello Stefan,

    thanks a lot for your time and help! RowStyle was just what I needed!
    Tim.
  13. Dimitri Rakviashvili
    Dimitri Rakviashvili avatar
    4 posts
    Member since:
    Apr 2010

    Posted 26 Aug 2010 Link to this post

    Tim, could you  provide full example of your code ? 
    Or could you explain how can i obtain this :

    util:SetterValueBindingHelper class ?

    Thanks
  14. Tim Tos
    Tim Tos avatar
    36 posts
    Member since:
    Apr 2010

    Posted 30 Aug 2010 Link to this post

    Hello Dimitri,

    sorry for the late response!
    I found the solution here!
    Hope this helps!

    Best Wishes,
    Tim.
  15. JJ Loubser
    JJ Loubser avatar
    42 posts
    Member since:
    Jul 2009

    Posted 15 Mar 2011 Link to this post

     radTreeListView_New.ExpandAllGroups();
     radTreeListView_New.ExpandAllHierarchyItems();
    not working in my case:

    try it to solve this problem:
    http://www.telerik.com/community/forums/silverlight/treelist/radtreelistview-containerbinding-not-binding.aspx



    used RowLoaded and RowUnLoaded,

    Error HRESULT E_FAIL has been returned from a call to a COM component

    at line:

    Row_.IsExpanded = oldRow_.IsExpanded;

    in:

    private RadTreeListView radTreeListView_;
            private bool mTreeViewListLeftScreen = false;
            private bool mTreeViewSetAllExapnd = false;
            public void radTreeViewlist_RowLoaded(object sender, Telerik.Windows.Controls.GridView.RowLoadedEventArgs e)
            {
                if (!mTreeViewListLeftScreen)
                {
                    radTreeListView_ = (RadTreeListView)sender;
                    if (radTreeListView_ != null && radTreeListView_.ItemsSource != null && radTreeListView_.Items.Count > 0)
                    {
                        
                        foreach (TreeViewListItem item in radTreeListView_.Items)
                        {
                            
                            if (radTreeListView_.ItemContainerGenerator.ContainerFromItem(item) != null && radTreeListView_.ItemContainerGenerator.ContainerFromItem(item) is TreeListViewRow)
                            {

                                TreeListViewRow Row_ = (TreeListViewRow)radTreeListView_.ItemContainerGenerator.ContainerFromItem(item);
                                item.IsItemCollectionExpanded = Row_.IsExpanded;
                                Row_.SetBinding(TreeListViewRow.IsExpandedProperty, new Binding()
                                                                                    {
                                                                                        Source = item,
                                                                                        Path = new PropertyPath("IsItemCollectionExpanded")
                                                                                    }
                                               );


                            }
                        }
                    }
                }
                else
                {
                    RadTreeListView radTreeListView_New = (RadTreeListView)sender;
                    if (radTreeListView_New != null && radTreeListView_New.ItemsSource != null && radTreeListView_New.Items.Count > 0)
                    {
                                          

                        foreach (TreeViewListItem item in radTreeListView_New.Items)
                        {
                           
                            if (radTreeListView_New.ItemContainerGenerator.ContainerFromItem(item) != null && radTreeListView_New.ItemContainerGenerator.ContainerFromItem(item) is TreeListViewRow)
                            {
                                foreach (TreeViewListItem olditem in radTreeListView_.Items)
                                {
                                    if (olditem.Id == item.Id)
                                    {
                                        if (radTreeListView_.ItemContainerGenerator.ContainerFromItem(olditem) != null && radTreeListView_.ItemContainerGenerator.ContainerFromItem(olditem) is TreeListViewRow)
                                        {
                                            TreeListViewRow Row_ = (TreeListViewRow)radTreeListView_New.ItemContainerGenerator.ContainerFromItem(item);
                                            TreeListViewRow oldRow_ = (TreeListViewRow)radTreeListView_.ItemContainerGenerator.ContainerFromItem(olditem);

                                            if (oldRow_.IsExpanded)
                                            {}
                                            Row_.IsExpanded = oldRow_.IsExpanded;
                                            
                                            Row_.SetBinding(TreeListViewRow.IsExpandedProperty, new Binding()
                                            {
                                                Source = item,
                                                Path = new PropertyPath("IsItemCollectionExpanded")
                                            }
                                               );

                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
  16. JJ Loubser
    JJ Loubser avatar
    42 posts
    Member since:
    Jul 2009

    Posted 15 Mar 2011 Link to this post

    working when I update this code:

    try
                                            {
                                                Row_.IsExpanded = oldRow_.IsExpanded;
                                                Row_.SetBinding(TreeListViewRow.IsExpandedProperty, new Binding()
                                                                                                    {
                                                                                                      Source = item,
                                                                                                      Path = new PropertyPath("IsItemCollectionExpanded")
                                                                                                    }
                                                               );
                                               
                                            }
                                            catch (Exception eeee)
                                            { }

    in:

     private RadTreeListView radTreeListView_;
            private bool mTreeViewListLeftScreen = false;
            private bool mTreeViewSetAllExapnd = false;
            public void radTreeViewlist_RowLoaded(object sender, Telerik.Windows.Controls.GridView.RowLoadedEventArgs e)
            {
                if (!mTreeViewListLeftScreen)
                {
                    radTreeListView_ = (RadTreeListView)sender;
                    if (radTreeListView_ != null && radTreeListView_.ItemsSource != null && radTreeListView_.Items.Count > 0)
                    {
                        
                        foreach (TreeViewListItem item in radTreeListView_.Items)
                        {
                            
                            if (radTreeListView_.ItemContainerGenerator.ContainerFromItem(item) != null && radTreeListView_.ItemContainerGenerator.ContainerFromItem(item) is TreeListViewRow)
                            {

                                TreeListViewRow Row_ = (TreeListViewRow)radTreeListView_.ItemContainerGenerator.ContainerFromItem(item);
                                item.IsItemCollectionExpanded = Row_.IsExpanded;
                                Row_.SetBinding(TreeListViewRow.IsExpandedProperty, new Binding()
                                                                                    {
                                                                                        Source = item,
                                                                                        Path = new PropertyPath("IsItemCollectionExpanded")
                                                                                    }
                                               );


                            }
                        }
                    }
                }
                else
                {
                    RadTreeListView radTreeListView_New = (RadTreeListView)sender;
                    if (radTreeListView_New != null && radTreeListView_New.ItemsSource != null && radTreeListView_New.Items.Count > 0)
                    {
                                          

                        foreach (TreeViewListItem item in radTreeListView_New.Items)
                        {
                           
                            if (radTreeListView_New.ItemContainerGenerator.ContainerFromItem(item) != null && radTreeListView_New.ItemContainerGenerator.ContainerFromItem(item) is TreeListViewRow)
                            {
                                foreach (TreeViewListItem olditem in radTreeListView_.Items)
                                {
                                    if (olditem.Id == item.Id)
                                    {
                                        if (radTreeListView_.ItemContainerGenerator.ContainerFromItem(olditem) != null && radTreeListView_.ItemContainerGenerator.ContainerFromItem(olditem) is TreeListViewRow)
                                        {
                                            TreeListViewRow Row_ = (TreeListViewRow)radTreeListView_New.ItemContainerGenerator.ContainerFromItem(item);
                                            TreeListViewRow oldRow_ = (TreeListViewRow)radTreeListView_.ItemContainerGenerator.ContainerFromItem(olditem);

                                            if (oldRow_.IsExpanded)
                                            {}
                                            try
                                            {
                                                Row_.IsExpanded = oldRow_.IsExpanded;
                                                Row_.SetBinding(TreeListViewRow.IsExpandedProperty, new Binding()
                                                                                                    {
                                                                                                      Source = item,
                                                                                                      Path = new PropertyPath("IsItemCollectionExpanded")
                                                                                                    }
                                                               );
                                               
                                            }
                                            catch (Exception eeee)
                                            { }

                                           

                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }

            public void radTreeViewlist_RowUnloaded(object sender, Telerik.Windows.Controls.GridView.RowUnloadedEventArgs e)
            {
               
            }


    just need to upgrade this code for 3 time + loads... Remember this is in ViewModel code not code behind...
Back to Top
DevCraft banner