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

Persist group expansion after databind

4 Answers 115 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Edmund Jung
Top achievements
Rank 1
Edmund Jung asked on 27 Apr 2009, 10:49 PM
Hello,

It seems that my grouping is collapsed when I rebind bind my grid to a datasource.

  1. Bind grid
  2. Drag column header to grouping panel
  3. Expand second group
  4. Rebind grid
  5. All groups are colapsed once again

Is there a way to determine which groups were expaned before the bind and then iterate through the new groups and if it finds a match, expand it?

Thank you, Tyler

4 Answers, 1 is accepted

Sort by
0
Nick
Telerik team
answered on 28 Apr 2009, 08:34 AM
Hi Edmund Jung,

You can expand groups programmatically using the Groups collection of MasterGridViewTemplate. For example, to expand the first group use the code below:

private void radButton1_Click(object sender, EventArgs e) 
            this.radGridView1.MasterGridViewTemplate.Groups[0].Expand();          
}   

Do not hesitate to write me back if you have further questions.

Greetings,
Nick
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
tyler thompson
Top achievements
Rank 1
answered on 28 Apr 2009, 04:57 PM
Thank you for your reply.  What I would like to do is determine which groups were expanded before the databind and persist their id's or summary name then after the databind, which collapses all groups, find those groups which were expanded before the databinding and then expand them.
 
If my grid looks like this...

-  State: California
                    Person 1      Address 1
                    Person 2      Address 2

+ State: Idaho
+ State: Texas

Is there any way for me to get the string "State: California" from the group header or some other kind of id that I can use to iterate through the new groups and see if a previously expanded group exists in the new groups collection.

Thank you for your help.
Tyler
0
Nick
Telerik team
answered on 29 Apr 2009, 08:36 AM
Hi tyler thompson,

Thank you for contacting us back. The code that you need in your scenario is the following:

private void radButton1_Click_1(object sender, EventArgs e) 
        { 
           foreach (DataGroup group in this.radGridView1.Groups) 
           { 
 
               if (group.IsExpanded) 
               { 
                   //save somewhere this.radGridView1.Groups[1].Aggregates[0].Value 
               } 
           } 
        }   

Do not hesitate to write me back if you have further questions.

All the best,
Nick
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
tyler thompson
Top achievements
Rank 1
answered on 29 Apr 2009, 03:50 PM
That was what I was looking for. Thank you.

Tyler
Tags
GridView
Asked by
Edmund Jung
Top achievements
Rank 1
Answers by
Nick
Telerik team
tyler thompson
Top achievements
Rank 1
Share this question
or