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

GroupsDefaultExpanded Specific Groups

2 Answers 96 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Karl Rohrbach
Top achievements
Rank 1
Karl Rohrbach asked on 30 Jun 2010, 11:09 PM
I have a RadGrid that has about 12 groups (grouped by months).   The GroupsDefaultExpanded (true/false) expands or collapses "ALL" the groups.  Is there a way to Expand "ONLY THE FIRST GROUP" within the 12 groups in the code behind? 

Example: 

January 2010 (Expanded)
    Items
    Items
    Items
February 2010 (Collapsed)
March 2010 (Collapsed)
April (Collapsed)
etc.

Thanks in advance for some guidance.

2 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 01 Jul 2010, 06:02 AM
Hello Karl,

You can try the following code snippet in ItemDataBound event to expand only the first Group.

C#:
 
 protected
 void RadGrid1_ItemDataBound1(object sender, GridItemEventArgs e) 
    { 
        if (e.Item is GridGroupHeaderItem) 
        { 
                GridGroupHeaderItem item = (GridGroupHeaderItem)e.Item; 
                if (item.GroupIndex == "0"
                    item.Expanded = true
        } 
   } 
     

Thanks,
Princy.
0
Karl Rohrbach
Top achievements
Rank 1
answered on 01 Jul 2010, 06:10 PM
Thanks Princy! 

I appreciate the guidance.  I implemented your suggestion and the behavior is as expected on ItemDataBound.  But I am not sure if I can implement it because the behavior when clicking on NestedViewTemplate items causes all of my rows within that grouping to dissapear.  It is very odd.   To further expand on the issue and what I need to accomplish.

1)  I need to expand the groupings that are coming up next month.
    a)  There could be two groupings that need to be expanded (ex. July 13 and July 25)
2)  I have items in the groupings that when clicked expose a NestedViewTemplate that contains a RadTabStrip, with has 3 RadPageViews containing a RadGrid in each.
3)  The behavior is a little strange with what you suggested.
    a)  July 13, 2010 is expanded.  But when I click on an Item in that group, all items dissapear including the item that was clicked.  The only thing that displays is the NestedViewTemplate item (with RadTabStrip). 



July 13, 2010 (Expanded)
    Item
        RadTabStrip (3 tabs)
            RadPageView/RadGrid
            RadPageView/RadGrid
            RadPageView/RadGrid
    Item
        RadTabStrip (3 tabs)
            RadPageView/RadGrid
            RadPageView/RadGrid
            RadPageView/RadGrid
    Item
        RadTabStrip (3 tabs)
            RadPageView/RadGrid
            RadPageView/RadGrid
            RadPageView/RadGrid            
July 25, 2010 (Expanded)
    Item
    Item
    Item
August 2010 (Collapsed)
September 2010 (Collapsed)
October (Collapsed)
etc.

Tags
Grid
Asked by
Karl Rohrbach
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Karl Rohrbach
Top achievements
Rank 1
Share this question
or