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

Setting Header Row Height

9 Answers 559 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Kumar
Top achievements
Rank 1
Kumar asked on 20 Sep 2011, 02:47 PM
Hello Telerik Team,

I wanted to reduce the height of the header row but cannot figure out how. Setting the RowHeight property works only for the rows and not for the header row.

Is there a way to reduce the height of the header row?

Thanks,
Kumar

9 Answers, 1 is accepted

Sort by
0
Vanya Pavlova
Telerik team
answered on 20 Sep 2011, 02:58 PM
Hello Kumar,

 

Indeed you are right - setting RadGridView's RowHeight property will affect only GridViewRows. If you want to change the Height of GridViewHeaderRow you may do this through defining a simple style targeted at GridViewHeaderRow, as shown below:


<Style TargetType="telerik:GridViewHeaderRow">
    <Setter Property="MinHeight" Value="10"/>
</Style>


You may also mark this style as an explicit one with the x:Key attribute and set it on a grid level through the HeaderRowStyle property.


 

Best wishes,
Vanya Pavlova
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Dawid
Top achievements
Rank 1
answered on 24 Dec 2019, 06:18 AM

Hi Vanya

I followed the method you provided but there seems to be another issue.

Implementing the styling seems to remove all other styling from my headers, leaving them blank but resized.

Has the functionality changed? Or is it perhaps because I am using implicit styles?

0
Dinko | Tech Support Engineer
Telerik team
answered on 25 Dec 2019, 02:48 PM

Hi Dawid,

This behavior could be a result of using NoXAML DLLs. Are you using one of our predefined themes? In such a scenario, custom implicit styles targeting our controls need to have BasedOn property set to the default style of the control. Otherwise, the implicit style will override the default one. You can read more about this in the Styling the Controls help article in our documentation. In your case, check the following code snippet.

<Style TargetType="telerik:GridViewHeaderRow" BasedOn="{StaticResource GridViewHeaderRowStyle}">
    <Setter Property="MinHeight" Value="10"/>
</Style>

Regards,
Dinko
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Dawid
Top achievements
Rank 1
answered on 27 Dec 2019, 05:35 AM

Hi Dinko

This solves the visibility issue, thank you. I am however still having an issue. Any value for the MinHeight property below 27 does not seem to affect the grid header height. I have also tried playing around with padding and margin but they do not seem to be the cause, do you have any suggestions to get past this?

Thanks

Dawid

0
Martin Ivanov
Telerik team
answered on 27 Dec 2019, 01:59 PM

Hello Dawid,

This happens because one of the elements in the GridViewHeaderRow template is having its MinHeight property set to 26. To avoid this limit you can subscribe to the RowLoaded event of RadGridView and set the MinHeight of this element in code. Here is an example in code:

private void RadGridView_RowLoaded(object sender, Telerik.Windows.Controls.GridView.RowLoadedEventArgs e)
{
	if (e.Row is GridViewHeaderRow)
	{
		e.Row.MinHeight = 10;
		var headerCell = e.Row.ChildrenOfType<Grid>().FirstOrDefault(x => x.Name == "PART_HeaderCellGrid");
		headerCell.MinHeight = 0;
	}
}

I hope this helps.

Regards,
Martin Ivanov
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Dawid
Top achievements
Rank 1
answered on 30 Dec 2019, 05:31 AM

Hi Martin

 

I tried this approach but i still don't get a reduced header height, could you perhaps provide a sample project as a demonstration?

 

Thanks in advance

Dawid

0
Martin Ivanov
Telerik team
answered on 30 Dec 2019, 09:28 AM

Hello Dawid,

I've attached my test project. I hope it helps.

Note that the project uses the Xaml version of the dlls.

Regards,
Martin Ivanov
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Dawid
Top achievements
Rank 1
answered on 30 Dec 2019, 12:29 PM

Hi Martin

 

Thank you for the response. I am using NoXaml dll's, will it require a different solution?

 

Kind regards

Dawid

0
Martin Ivanov
Telerik team
answered on 30 Dec 2019, 01:49 PM

Hello Dawid,

No, the solution is the same, but the setup will be sightly different. You will need to reference also the Telerik theme dll and merge the corresponding resources as shown in the Setting a Theme article.

Regards,
Martin Ivanov
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
GridView
Asked by
Kumar
Top achievements
Rank 1
Answers by
Vanya Pavlova
Telerik team
Dawid
Top achievements
Rank 1
Dinko | Tech Support Engineer
Telerik team
Martin Ivanov
Telerik team
Share this question
or