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

Need a way to hide blank groups

1 Answer 45 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Gabriele
Top achievements
Rank 1
Gabriele asked on 04 Nov 2010, 05:49 PM
Hi,

I am using RadGrid with grouping.

I am grouping by 4 fields in the table that represent the outline level in an Excel spreadsheet that I am transfering to a database.
4 is the maximum number of levels I have but not all the rows use up to 4 levels.

there is a way to remove/Hide group levels that are blank?

See the attached picture.

Thanks,

-Gabriele

1 Answer, 1 is accepted

Sort by
0
Veli
Telerik team
answered on 09 Nov 2010, 02:33 PM
Hello Gabriele,

You can use RadGrid's PreRender event to find the group header items and hide them based on their header cell content:

Copy Code
protected void Page_PreRender(object sender, EventArgs e)
{
    GridItem[] groupHeaders = RadGrid1.MasterTableView.GetItems(GridItemType.GroupHeader);
    foreach (GridItem item in groupHeaders)
    {
        GridGroupHeaderItem groupHeader = item as GridGroupHeaderItem;
        if (groupHeader.DataCell.Text.Contains("text to check for"))
        {
            groupHeader.Visible = false;
        }
    }
}

Greetings,
Veli
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Grid
Asked by
Gabriele
Top achievements
Rank 1
Answers by
Veli
Telerik team
Share this question
or