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

How to adjust RadGridView child table row height?

3 Answers 384 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Stanley
Top achievements
Rank 1
Stanley asked on 23 Jul 2012, 08:38 AM
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 

3 Answers, 1 is accepted

Sort by
0
Accepted
Svett
Telerik team
answered on 24 Jul 2012, 03:03 PM
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 >>
0
Victor
Top achievements
Rank 1
answered on 03 May 2017, 03:52 PM

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;
           }
            
       }

 

0
Hristo
Telerik team
answered on 05 May 2017, 04:21 PM
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.
Tags
GridView
Asked by
Stanley
Top achievements
Rank 1
Answers by
Svett
Telerik team
Victor
Top achievements
Rank 1
Hristo
Telerik team
Share this question
or