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

[Solved] Collapsed hierarchy by default when grouped

3 Answers 618 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Condorito
Top achievements
Rank 1
Condorito asked on 26 Jun 2009, 12:34 PM
Hi, I have a hierarchical Grid with ShowGroupPanel set to true.  Our specs require that when the users group by a column, both the grouping and the hierarchy for each row inside that group should be collapsed.  I can accomplish the grouping part by setting the GroupsDefaultExpanded property to false, but when users expand each grouping, each underlying row will have its details expanded by default.   HierarchyDefaultExpanded = False only seems to work when no grouping is taking place.   Is there any way I can accomplish this without posting back to the server, either by setting a property to a specific value or through client-side code?   Thank you.

3 Answers, 1 is accepted

Sort by
0
Veli
Telerik team
answered on 01 Jul 2009, 11:14 AM
Hi Juan,

If I understood you correctly, you have both grouping and hierarchy defined in RadGrid. And your grouped items have their detail tables expanded when group is expanded. If my assumption is correct, please check if you haven't specified HierarchyDefaultExpanded="true" in RadGrid's MasterTableView, that causes your detail tables to be shown all the time the parent is visible.

MasterTableView's properties HierarchyDefaultExpanded and GroupsDefaultExpanded determine the default expanded states for grouping and hierarchical table views. Please check these settings to make sure everyting is as required.

Greetings,
Veli
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Condorito
Top achievements
Rank 1
answered on 02 Jul 2009, 03:25 PM
Hi Veli,

Thank you for your response.  Yes, you understood correctly.  I haven't specified the HierarchyDefaultExpanded property anywhere.  I only have GroupsDefaultExpanded set to false.  I set HierarchyDefaultExpanded="false" just to see what would happens, and then took it out.  The behavior was the same.  If I group the grid by a column, the grouped item rows are collapsed, as expected, but when I click on the expand icon for a particular group, both the rows and the details for those rows are expanded by default. 

I can't figure out how to set up the grid so that, when the users click on the expand icon for a group, the rows that are shown have their details collapsed by default.  Thank you.
0
Princy
Top achievements
Rank 2
answered on 06 Jul 2009, 06:05 AM
Hello Juan,

You can try out the following code to achieve your scenario:
c#:
protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e) 
    { 
        foreach (GridGroupHeaderItem groupHeader in RadGrid1.MasterTableView.GetItems(GridItemType.GroupHeader)) 
        {  
                GridItem[] children = groupHeader.GetChildItems(); 
                foreach (GridItem child in children) 
                { 
                    if (child.Expanded)                     
                        child.Expanded = false;                    
                }            
        } 
    } 

Thanks
Princy.
Tags
Grid
Asked by
Condorito
Top achievements
Rank 1
Answers by
Veli
Telerik team
Condorito
Top achievements
Rank 1
Princy
Top achievements
Rank 2
Share this question
or