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

Hiding a Group Header When value is empty

2 Answers 180 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jeff
Top achievements
Rank 1
Jeff asked on 19 Jan 2010, 05:33 PM

There are a couple of other posts related to hiding a Group Header but I believe this circumstance is a bit different.

 

We have a hierarchical Grid with the following levels:

Track > Course > Lesson

 

The Lessons within a course are then grouped by Chapters. But some of the courses have no chapters - just a series of lessons. In those cases we want to hide the group header. It is not a case where there are no items, it is just that the related chapter grouping is "null".

Is there a way to check that if the group value that is returned is "null" (or a specific value if that is easier) and then hide the group header and expand/collapse button if that is the case?

thanks

2 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 20 Jan 2010, 10:48 AM
Hello Jeff,

You can try out the following example to hide the GroupHeaderItem when it displays no value:
c#:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) 
    { 
        if (e.Item is GridGroupHeaderItem) 
        { 
            GridGroupHeaderItem gpHeader = e.Item as GridGroupHeaderItem;   
            if(gpHeader.DataCell.Text.Substring(gpHeader.DataCell.Text.IndexOf(":") + 1) == " "
            { 
                gpHeader.Display = false
            } 
        } 
    }  

Thanks
Princy.
0
Jeff
Top achievements
Rank 1
answered on 20 Jan 2010, 04:03 PM
Thanks - that worked great
Tags
Grid
Asked by
Jeff
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Jeff
Top achievements
Rank 1
Share this question
or