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

Dynamically Resize GridHeaderRowElement?

3 Answers 124 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Michael
Top achievements
Rank 1
Michael asked on 12 Aug 2009, 02:36 PM
In order to try to bend the will of the GridView to do something we're attempting, I'm trying to dynamically either completely hide or to change the height of a SPECIFIC group header row down to something 1 pixel in height if the group text is blank.

I've tried all of the following:

 
            if (e.RowElement is GridGroupHeaderRowElement) 
            { 
                e.RowElement.Size = new Size(1, 1); 
                 
                e.RowElement.ShouldPaint = false
                e.RowElement.Visibility = ElementVisibility.Hidden; 
                e.RowElement.MinSize = new Size(e.RowElement.Size.Width, 0); 
                e.RowElement.Size = new Size(e.RowElement.Size.Width, 1); 
                e.RowElement.CoercedSize = new Size(e.RowElement.Size.Width, 1); 
                e.RowElement.StretchVertically = false
                this.ApplyThemeToElement(e.RowElement, "ControlDefault"); 
            }

All this has done has completely hidden the group rows but still leaves blank space where they shuold be, however now I can't select them (which is nice).

Is there any way to change the size so the space left when hidden is minimized?

Thanks in advance.

3 Answers, 1 is accepted

Sort by
0
Jack
Telerik team
answered on 13 Aug 2009, 07:34 AM
Hello Michael,

The following code is enough to hide the group rows. You have to set only GridElement.GroupHeaderHeight property:

this.radGridView1.GridElement.GroupHeaderHeight = 0; 

I hope this helps. Should you have any further questions, don't hesitate to write back.

Kind regards,
Jack
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
Michael
Top achievements
Rank 1
answered on 13 Aug 2009, 06:32 PM
Jack,

This solution reduces the height of ALL group headers.

I want to do it to a specific groups headers. Basically, if the header's test is an empty string, I want to collapse the group header so it's not visible.


0
Jack
Telerik team
answered on 14 Aug 2009, 12:37 PM
Hello Michael,

Thank you for this clarification. Now I understand what do you want to achieve. In this case you should replace the default TableViewDefinition and override its GetRowHeight method. Here is a sample:

this.radGridView1.ViewDefinition = new CustomTableViewDefinition(); 
 
public class CustomTableViewDefinition: TableViewDefinition 
    public override int GetRowHeight(GridViewRowInfo rowInfo, IGridView gridView) 
    { 
        GridViewGroupRowInfo groupRowInfo = rowInfo as GridViewGroupRowInfo;             
        if (groupRowInfo != null && string.IsNullOrEmpty(groupRowInfo.GetSummary())) 
        { 
            return 0; 
        }  
        return base.GetRowHeight(rowInfo, gridView); 
    } 

If you need further assistance, I will be glad to help.

All the best,
Jack
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.
Tags
GridView
Asked by
Michael
Top achievements
Rank 1
Answers by
Jack
Telerik team
Michael
Top achievements
Rank 1
Share this question
or