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

Iterate through expanded grid groups only?

2 Answers 223 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Michael
Top achievements
Rank 1
Michael asked on 04 Jan 2013, 03:18 PM
I am working with a grid that utilizes about 3 levels of nested grouping.  On page load, some of the grid groups are expanded or contracted based on criteria. I am interested in iterating through the grid and only grabbing a collection of rows that are currently visible due to the groups that are currently expanded.  Is this possible?

2 Answers, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 09 Jan 2013, 12:19 PM
Hello Michael, 

You can use the following approch:
protected void Button1_Click(object sender, EventArgs e)
{
    foreach (GridGroupHeaderItem groupHeader in RadGrid1.MasterTableView.GetItems(GridItemType.GroupHeader))
    {
        if (groupHeader.Expanded)
        {
            foreach (GridItem item in groupHeader.GetChildItems())
            {
                if (item is GridDataItem)
                {
                    item.BackColor = Color.LightBlue;
                }
            }
        }
    }
}

That should do the trick. Please give it a try and let me know if it works for you.

Kind regards,
Eyup
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Michael
Top achievements
Rank 1
answered on 09 Jan 2013, 02:49 PM
That works,

Thanks!
Tags
Grid
Asked by
Michael
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Michael
Top achievements
Rank 1
Share this question
or