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

Automatically expand all nodes in RadTreeListView v2010.2.714 by default

14 Answers 320 Views
TreeListView
This is a migrated thread and some comments may be shown as answers.
Rami Abughazaleh
Top achievements
Rank 1
Rami Abughazaleh asked on 17 Jul 2010, 01:32 AM
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.

14 Answers, 1 is accepted

Sort by
0
Mike
Top achievements
Rank 1
answered on 18 Jul 2010, 12:37 PM
I was able to resolve this issue by calling the ExpandAllHierarchyItems() method on the RadTreeListView.
0
Stephen
Top achievements
Rank 1
answered on 21 Jul 2010, 04:24 PM
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
0
Andy Fry
Top achievements
Rank 1
answered on 21 Jul 2010, 10:48 PM
I am also interested in how you bind the IsExpanded property to a property on the objects that I have the TreeListView bound to.
0
Rami Abughazaleh
Top achievements
Rank 1
answered on 21 Jul 2010, 11:59 PM
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
0
Stefan Dobrev
Telerik team
answered on 23 Jul 2010, 11:46 AM
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
0
David Schnebly
Top achievements
Rank 1
answered on 27 Jul 2010, 03:11 PM
Is there an estimated time when container bindings will be working for the RadTreeListView?
0
Stefan Dobrev
Telerik team
answered on 30 Jul 2010, 10:57 AM
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
0
Tim Tos
Top achievements
Rank 1
answered on 31 Jul 2010, 07:46 AM
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.
0
Stefan Dobrev
Telerik team
answered on 04 Aug 2010, 10:33 AM
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
0
Tim Tos
Top achievements
Rank 1
answered on 05 Aug 2010, 07:01 AM
Hello Stefan,

thanks a lot for your time and help! RowStyle was just what I needed!
Tim.
0
Dimitri Rakviashvili
Top achievements
Rank 1
answered on 26 Aug 2010, 12:49 PM
Tim, could you  provide full example of your code ? 
Or could you explain how can i obtain this :

util:SetterValueBindingHelper class ?

Thanks
0
Tim Tos
Top achievements
Rank 1
answered on 30 Aug 2010, 04:39 PM
Hello Dimitri,

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

Best Wishes,
Tim.
0
JJ Loubser
Top achievements
Rank 1
answered on 15 Mar 2011, 10:25 AM
 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")
                                        }
                                           );

                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
0
JJ Loubser
Top achievements
Rank 1
answered on 15 Mar 2011, 11:03 AM
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...
Tags
TreeListView
Asked by
Rami Abughazaleh
Top achievements
Rank 1
Answers by
Mike
Top achievements
Rank 1
Stephen
Top achievements
Rank 1
Andy Fry
Top achievements
Rank 1
Rami Abughazaleh
Top achievements
Rank 1
Stefan Dobrev
Telerik team
David Schnebly
Top achievements
Rank 1
Tim Tos
Top achievements
Rank 1
Dimitri Rakviashvili
Top achievements
Rank 1
JJ Loubser
Top achievements
Rank 1
Share this question
or