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

AutoSizeRows for data rows only

3 Answers 200 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Phil
Top achievements
Rank 1
Phil asked on 19 Jan 2016, 08:39 PM

I have a RadGridView using the VisualStudio2012Light theme which is exactly the style I want - I don't want anything to change when it comes to that at all, not the headers, summary rows, add new row, etc.

I have some columns with WrapText enabled so they will stretch and auto size their parent rows where needed if AutoSizeRows is enabled.

Now the problem comes in when AutoSizeRows is enabled. All non-data rows resize as well, breaking whatever heights were set as part of the theme. For maintainability I don't want to have to add explicit overrides/adjustments for heights in case the theme changes at a later stage. I am very happy with the theme and only want the rows to stretch in size and to never shrink below what the theme dictates.

I'm using 2016 Q1 and am battling to find the correct event and property combinations to only allow my data rows to resize - I figured that preventing autosizing of non-data rows is probably the cleanest fix for now I don't know if there is any request perhaps to prevent AutoSizeRows from shrinking already themed heights?

I've tried using the CreateRow event but can't figure out how to change enable/disable from there. The GridViewCreateRowEventArgs object has a RowElement property which hasn't been instantiated yet since the row doesn't exist. Must I instantiate that myself to set AutoSize to false? How would I create a default RowElement without changing anything else but that? If I can't use e.RowElement, how do I use e.RowInfo to set AutoSize to false?

I've tried using the RowFormatting event but to no avail.

 Any assistance on this would be greatly appreciated.

 

 

3 Answers, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 20 Jan 2016, 09:34 AM
Hi Phil,

Thank you for writing.

In order to use the default row height when the rows are auto-sized, you should set their minimum height. The following snippet shows how you can set the default and the minimum height for the system rows:
radGridView1.MasterView.TableSearchRow.MinHeight = 30;
radGridView1.MasterView.TableHeaderRow.MinHeight = 30;
radGridView1.MasterView.TableFilteringRow.MinHeight = 30;
 
radGridView1.TableElement.TableHeaderHeight = 30;
radGridView1.TableElement.SearchRowHeight = 30;
radGridView1.TableElement.FilterRowHeight = 30;

I hope this will be useful. 

Regards,
Dimitar
Telerik
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 Feedback Portal and vote to affect the priority of the items
0
Moi
Top achievements
Rank 1
answered on 13 Jun 2019, 01:03 PM

Hi,

And when I have a master-details gridview, how to set a min size for the child view ?

Thank you

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 18 Jun 2019, 06:05 AM
Hello, Moi,          

Dimitar is out of office this week so I will be assisting you with this case.

In order o adjust the height for the header row, filtering row and the search row in the child template, you can refer to the following code snippet: 

int height = 40;

foreach (GridViewRowInfo row in this.radGridView1.Rows)
{
    if (row.ChildRows.Count > 0)
    {
        row.ChildRows[0].ViewInfo.TableHeaderRow.MinHeight = height;
        row.ChildRows[0].ViewInfo.TableFilteringRow.MinHeight = height;
        row.ChildRows[0].ViewInfo.TableSearchRow.MinHeight = height;
    }
}



I hope this information helps. If you need any further assistance please don't hesitate to contact me. 

Regards,
Dess | Tech Support Engineer, Sr.
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
Phil
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Moi
Top achievements
Rank 1
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or