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

ExpandAllHierarchyItems in three level hierarchy

10 Answers 418 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Orit
Top achievements
Rank 1
Orit asked on 02 Feb 2010, 09:39 AM
Hello

I have a three level hierarchy grid
and I want to open all the expand buttons at once (by a button click)
If I use 

RadGridview1.ExpandAllHierarchyItems()
it opens only the first level
how can I open the second level?
I tried to do this

 

RadGridview1.ChildrenOfType<

RadGridView>().FirstOrDefault().ExpandAllHierarchyItems();
but only the children of the first child are open.

Thanks

 

10 Answers, 1 is accepted

Sort by
0
Accepted
Vlad
Telerik team
answered on 02 Feb 2010, 09:52 AM
Hello,

Please check this thread for more info:
http://www.telerik.com/community/forums/silverlight/gridview/calling-expandallhierarchyitems-doesn-t-expand-all-child-tables.aspx

The same approach can be used with WPF.

Sincerely yours,
Vlad
the Telerik team

Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Follow the status of features or bugs in PITS and vote for them to affect their priority.
0
Orit
Top achievements
Rank 1
answered on 02 Feb 2010, 10:00 AM

Thank you!
0
Orit
Top achievements
Rank 1
answered on 02 Feb 2010, 11:13 AM

Sorry but just now I notice
that also if I open a row by clicking on its expand button
all his children are also open

what I need is-
if I click a button, all the rows will be open
but if I click an expand button of a row
only the row will be opened and not all it children too
 I tried to do this
bool bExpand = false;  
       private void btnExpand_Click(object sender, RoutedEventArgs e)  
       {  
           try  
           {  
               bExpand = true;  
               gvAccount.ExpandAllHierarchyItems();                  
           }  
           catch (Exception ex)  
           {  
               MessageBox.Show(ex.ToString());  
           }  
       }        
 
       private void RadGridView1_DataLoading(object sender, Telerik.Windows.Controls.GridView.GridViewDataLoadingEventArgs e)  
       {  
             
               var dataControl = (GridViewDataControl)sender;  
               if (dataControl.ParentRow != null)  
               {  
                   if (bExpand)  
                   {  
                       dataControl.Loaded -dataControl_Loaded;  
                       dataControl.Loaded += dataControl_Loaded;  
                   }  
                   else   
                   {  
                       dataControl.Loaded -dataControl_Loaded;  
                   }  
               }      
       }  
      
       void dataControl_Loaded(object sender, RoutedEventArgs e)  
       {  
           if (bExpand)  
           {  
               ((GridViewDataControl)sender).ExpandAllHierarchyItems();  
           }  
       } 

but it doesnot work good

any solution for this?

Thanks
0
Vlad
Telerik team
answered on 05 Feb 2010, 01:47 PM
Hello,

You can find an example application attached.

Regards,
Vlad
the Telerik team

Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Follow the status of features or bugs in PITS and vote for them to affect their priority.
0
Orit
Top achievements
Rank 1
answered on 07 Feb 2010, 06:19 AM
Thank you for the example
but I still dont use Q3 so I dont have the  GridViewToggleButton
do you have any solution for Q2 ?
0
Vlad
Telerik team
answered on 08 Feb 2010, 12:02 PM
Hi,

With Q2 you can use ToggleButton instead GridViewToggleButton.

Greetings,
Vlad
the Telerik team

Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Follow the status of features or bugs in PITS and vote for them to affect their priority.
0
Orit
Top achievements
Rank 1
answered on 08 Feb 2010, 12:10 PM

I try to do this
var toggleButton = row.ChildrenOfType<ToggleButton>().FirstOrDefault();
but I get an error
The type or namespace name 'ToggleButton' could not be found (are you missing a using directive or an assembly reference?) 

 

 

0
Milan
Telerik team
answered on 08 Feb 2010, 12:18 PM
Hi Orit,

ToggleButton is in the System.Windows.Controls.Primitives namespace of the System.Windows assembly.

Regards,
Milan
the Telerik team

Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Follow the status of features or bugs in PITS and vote for them to affect their priority.
0
Orit
Top achievements
Rank 1
answered on 11 Feb 2010, 07:52 AM
Thank you

I still hvae one question
I have a button that has to collapse all the rows
how can I do it?
again, the CollapseAllHierarchyItems
collapse only the first level.

0
Pavel Pavlov
Telerik team
answered on 17 Feb 2010, 09:40 AM
Hi Orit,

Please try the following code:
private void Button_Click(object sender, RoutedEventArgs e)
{
    foreach (var grid in this.RadGridView1.ChildrenOfType<GridViewDataControl>())
    {
        grid.CollapseAllHierarchyItems();
    }
    this.RadGridView1.CollapseAllHierarchyItems();
}


You will need to add a using Telerik.Windows.Controls in order to use the ChildrenOfType extension method.

Regards,
Pavel Pavlov
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.
Tags
GridView
Asked by
Orit
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Orit
Top achievements
Rank 1
Milan
Telerik team
Pavel Pavlov
Telerik team
Share this question
or