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

Expand / Collapse SelfReference Hierarchy

1 Answer 63 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Arun Kumar
Top achievements
Rank 2
Arun Kumar asked on 30 Jun 2011, 09:11 AM
Hi All,

I want to expand / collapse all rows on button click event. I tried the dgv.MasterTemplate.ExpandAll() 
and dgv.MasterTemplate.CollapseAll() functions but none of them work. 

I have around 8000 rows and 6 levels. How do I do that?

Also I noticed, I expanded one group that has more than 2000 rows will take some seconds to expand and then I expand another one which has only 2 rows that also take same time of previous group. If I collapse previous group and then expand the second one it expanded quickly.  Is this normal behavior?

Thanks in advance

1 Answer, 1 is accepted

Sort by
0
Richard Slade
Top achievements
Rank 2
answered on 30 Jun 2011, 10:29 AM
Hello,

To expand and collapse all rows, you can use the following code:

Expand
radGridView1.GridElement.BeginUpdate();
foreach (GridViewDataRowInfo row in radGridView1.Rows)
{
    row.IsExpanded = true;
}
radGridView1.GridElement.EndUpdate();

Collapse
radGridView1.GridElement.BeginUpdate();
foreach (GridViewDataRowInfo row in radGridView1.Rows)
{
    row.IsExpanded = false;
}
radGridView1.GridElement.EndUpdate();

With regard to the performance issue that you've mentioned, there is a current known issue in this area. For more information on this, please take a look at this forum thread

Hope that helps
Richard
Tags
GridView
Asked by
Arun Kumar
Top achievements
Rank 2
Answers by
Richard Slade
Top achievements
Rank 2
Share this question
or