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

RadGridView set header row height dynamically

8 Answers 603 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Simon
Top achievements
Rank 1
Simon asked on 01 Nov 2017, 02:44 AM
How can I programmatically set a RadGridView's header row height dynamically, i.e. after the grid has been displayed?

8 Answers, 1 is accepted

Sort by
0
Dilyan Traykov
Telerik team
answered on 03 Nov 2017, 01:19 PM
Hello Simon,

You can get ahold of the GridViewHeaderRow and set its Height once the control is loaded in the following manner:

this.RadGridView.ChildrenOfType<GridViewHeaderRow>().First().Height = 50;

Please let me know whether such an approach would work for you.

Regards,
Dilyan Traykov
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
Simon
Top achievements
Rank 1
answered on 06 Nov 2017, 08:12 PM

It works, thanks.  But unfortunately the header text, filter icon and background styling all disappear when I do that.  It looks like I am encountering the same problem as described in the "Header Row Height" thread:

https://www.telerik.com/forums/header-row-height-372b12dc8630.

0
Dilyan Traykov
Telerik team
answered on 08 Nov 2017, 02:24 PM
Hello Simon,

Updating the header height using the aforementioned approach does not seem to result in any issues at my end as can be observed in the short video I've attached. I've also provided the sample project I've used in the process.

Can you please have a look and let me know if I'm missing something of importance? I look forward to your reply.

Regards,
Dilyan Traykov
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
Simon
Top achievements
Rank 1
answered on 08 Nov 2017, 07:49 PM

Hello Dilyan,

Thanks for the sample code and video.  Clearly header row height resizing works in that context may very well work for anyone else reading this thread to find out how.

Header row height resizing does not work in the the context of the very extensive customisation of the grid in my application.  Unfortunately, I cannot work out what the significant difference may be.

Similarly, I cannot work out what it is about the extensive grid customisation that has caused the bug that I hoped setting the header height might fix:  if a grid is initially shown with the rightmost few grid columns obscured by the the right edge of the grid, and even then only in certain very specific cases, the automatic sizing of the header makes it too tall to fit the header cell texts.  If this is a bug in RadGridView and not just in my application, I cannot properly report it with clear steps to reproduce it.

However, you have provided valuable information that has helped me fix my application bug.  Though I cannot directly change the header row height, I can at least find out what it is, like this:

this.RadGridView.ChildrenOfType<GridViewHeaderRow>().First().ActualHeight;

So I fixed my application bug by checking whether the header row is too tall and then, if it is, forcing the height to be correctly refreshed by programatically scrolling horizontally to the right end of the grid and then to the left end.  The user sees a flicker, which is not ideal.  But it works and only needs to be done fairly rarely.

Cheers,

Simon

0
Stefan
Telerik team
answered on 13 Nov 2017, 12:25 PM
Hi Simon,

Thank you for the detailed update.

By the time being we are not aware of such issue of RadGridView as per your report. Thus, my best guess is that it is related to the particular project setup. If you manage to isolate and demonstrate it in a simplified application, please ,contact us and we will gladly assist you further.

Nevertheless, it is nice to hear you have a workaround that you find suitable for your needs. If any other assistance with our components is required, do not hesitate to contact us as well.

All the best,
Stefan
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
Simon
Top achievements
Rank 1
answered on 15 Nov 2017, 12:48 AM

Hello Stefan,

My colleague Geordie has just posted a Bug Report with ID 1140284, "Header row can be too tall when column widths are set on loading".  The bug report includes a simple demo application, which I cannot upload to the forum.  However, for the interest of anyone reading this thread, I repeat the text of the bug report below.  As you will see, we have discovered many simple workarounds.  So I have been able to implement a much simpler workaround in my production application than the one described in my previous post.

DESCRIPTION OF BUG

If column widths are set on loading a grid and some of the columns are initially wholly scrolled out of view beyond the right edge of the grid, the header row can be initially shown much taller than would be necessary to fit the texts in all the header cells.

If, in the same situation, the header row height is also set on loading the grid, the header row will be initially shown at the specified height, but all the header cells will be empty, containing neither text nor the funnel-shaped filtering icons.

The header row will only be initially shown incorrectly, in either of the ways described above, if all of the following are true of the initial configuration in XAML of the leftmost one of the columns that are initially wholly scrolled out of view:

- The column's header text is of a certain type, which may possibly depend on the texts in the header cells of the other columns.  The rule has not been established but, at least in the demo application, "Alarm Queue Buzzer" results in the problem, while "Alarm Queue" does not.
- The column's width is specified.
- The TextWrapping property of the column header's TextBlock is set to Wrap.  Neither NoWrap nor WrapWithOverflow results in the problem.

Furthermore, regardless of the initial configuration in XAML of the problematic column, the problem will not occur if the column widths are set after initialising the grid instead of on loading it.

When the problem does occur, the user can remedy it by widening the grid.

Cheers,

Simon

0
Simon
Top achievements
Rank 1
answered on 15 Nov 2017, 06:52 PM
0
Tene
Top achievements
Rank 1
answered on 24 May 2018, 12:04 PM

I have the same problem and resolve it by applying the at the "RadGridView" global level:

  this.radGridView.ColumnWidth = new GridViewLength(1, GridViewLengthUnitType.Star);

with "radGridView" an object of type "RadGridView"

It works and the columns are not flicking anymore

 

 

Tags
GridView
Asked by
Simon
Top achievements
Rank 1
Answers by
Dilyan Traykov
Telerik team
Simon
Top achievements
Rank 1
Stefan
Telerik team
Tene
Top achievements
Rank 1
Share this question
or