AutoSizeRows for data rows only

4 posts, 0 answers
  1. Phil
    Phil avatar
    26 posts
    Member since:
    Oct 2012

    Posted 19 Jan 2016 Link to this post

    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.



  2. Dimitar
    Dimitar avatar
    2960 posts

    Posted 20 Jan 2016 Link to this post

    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. 

    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
  3. Moi
    Moi avatar
    3 posts
    Member since:
    May 2019

    Posted 13 Jun 2019 in reply to Dimitar Link to this post


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

    Thank you

  4. Dess | Tech Support Engineer, Sr.
    Dess | Tech Support Engineer, Sr.  avatar
    4125 posts

    Posted 18 Jun 2019 Link to this post

    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. 

    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.
Back to Top