How to adjust RadGridView child table row height?

4 posts, 1 answers
  1. Stanley
    Stanley avatar
    32 posts
    Member since:
    Apr 2012

    Posted 23 Jul 2012 Link to this post

    For parent row is like below
    RadGridView .TableElement.RowHeight = 100;

    How to adjust RadGridView ChildRowHeight?
    Its does not work after set.
    RadGridView.TableElement.ChildRowHeight = 100; 

    How to adjust child table row height?

    Please refer the picture from attachment.
    http://www.telerik.com/ClientsFiles/375753_ChildRowHeight.png 
  2. Answer
    Svett
    Admin
    Svett avatar
    728 posts

    Posted 24 Jul 2012 Link to this post

    Hello Stanley,

    You can change the height of the child rows by using the ViewCellFormatting event of RadGridView:
    private void radGridView1_ViewCellFormatting(object sender, CellFormattingEventArgs e)
    {
        GridDetailViewCellElement cell = e.CellElement as GridDetailViewCellElement;
     
        if (cell != null)
        {
            cell.ChildTableElement.RowHeight = 100;
        }
    }

    I hope this helps.

    All the best,
    Svett
    the Telerik team
    RadControls for WinForms Q2'12 release is now live! Check out what's new or download a free trial >>
  3. Victor
    Victor avatar
    3 posts
    Member since:
    Mar 2016

    Posted 03 May in reply to Svett Link to this post

    I have two views and I want to give each one a different height as seen in the attached image please!

    private void MasterTemplate_ViewCellFormatting(object sender, CellFormattingEventArgs e)
           {
               try
               {
                   var cell = e.CellElement as GridDetailViewCellElement;
     
                   if (cell != null)
                   {
                       cell.ChildTableElement.RowHeight = 44;
     
                       if (MyRadGridView.Templates[0].Caption == @"Detalle del Cargo")
                       {
                           cell.ChildTableElement.RowHeight = 100;
                       }
                   }
               }
               catch (Exception)
               {
                    
                   throw;
               }
                
           }

     

  4. Hristo
    Admin
    Hristo avatar
    949 posts

    Posted 05 May Link to this post

    Hello Victor,

    Thank you for writing.

    Having multiple views on the same level requires a slightly different approach. In order to accomplish your task, you can handle the ChildViewExpanded and MousUp events of the grid. Please check my code snippet below: 
    private void RadGridView1_ChildViewExpanded(object sender, ChildViewExpandedEventArgs e)
    {
        GridViewHierarchyRowInfo hierarhyRow = e.ParentRow as GridViewHierarchyRowInfo;
        if (hierarhyRow != null && hierarhyRow.IsExpanded)
        {
            GridTableElement table = this.radGridView1.GridViewElement.GetRowView(hierarhyRow.Views[0]) as GridTableElement;
            table.RowHeight = 100;
        }
    }
     
    private void RadGridView1_MouseUp(object sender, MouseEventArgs e)
    {
        RadGridView grid = (RadGridView)sender;
        RadPageViewStripItem tab = grid.ElementTree.GetElementAtPoint(e.Location) as RadPageViewStripItem;
        if (tab != null)
        {
            GridViewInfo view = (GridViewInfo)tab.Tag;
            GridTableElement table = grid.GridViewElement.GetRowView(view) as GridTableElement;
            if (table.ViewTemplate.Caption == "ChildTemplate1")
            {
                table.RowHeight = 100;
            }
            else if(table.ViewTemplate.Caption == "ChildTemplate2")
            {
                table.RowHeight = 50;
            }
            else
            {
                table.RowHeight = 24;
            }
        }
    }

    I  hope this helps. Should you have further questions please do not hesitate to write back.

    Regards,
    Hristo
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top