Completed
Last Updated: 07 Mar 2014 07:24 by ADMIN
Svetlin
Created on: 22 Mar 2013 04:00
Category: GridView
Type: Bug Report
4
FIX. The row's MaxHeight property does not affect the row sizing when the AutoSizeRows property of RadGridView is enabled.
The row's MaxHeight property does not affect the row sizing when the AutoSizeRows property of RadGridView is enabled.

Workaround:
Use the following data row:

public class MyGridDataRowElement : GridDataRowElement
{
protected override Type ThemeEffectiveType
{
get
{
return typeof(GridDataRowElement);
}
}
protected override System.Drawing.SizeF MeasureCore(System.Drawing.SizeF availableSize)
{
float maxHeight = this.RowInfo.MaxHeight;
bool isAutoSize = this.GridViewElement.AutoSize && this.RowInfo.MaxHeight > 0 && availableSize.Height == float.PositiveInfinity;
SizeF size = base.MeasureCore(availableSize);

if (isAutoSize && size.Height > maxHeight)
{
availableSize.Height = maxHeight;
size = base.MeasureCore(availableSize);
}

return size;
}
}

here is how to replace it and set the max height:
void radGridView1_RowFormatting(object sender, RowFormattingEventArgs e)
{
e.RowElement.RowInfo.MaxHeight = 32;
}

void radGridView1_CreateRow(object sender, GridViewCreateRowEventArgs e)
{
if (e.RowType == typeof(GridDataRowElement))
{
e.RowType = typeof(MyGridDataRowElement);
}
}
4 comments
ADMIN
Stefan
Posted on: 07 Mar 2014 07:24
Hi Martin,

this case here is not related to your question. I found the ticket you talked about and we will contact you in it with information about the requested functionality.
Martin Hamilton
Posted on: 07 Mar 2014 02:18
Stefan

I do apologize if I posted this query in the wrong spot... it wouldn't be the first time:)

I was referring to the sub-grid of RadGridView where there are two sub-grids at the same level.

The first tab shows the row at say 24px but the second tab has a formatted billing address that is perhaps 120px.

But the second tab doesn't auto-size itself.

I put in a ticket and received the following response;
Private Sub radGridView1_ViewCellFormatting(sender As Object, e As CellFormattingEventArgs)
    Dim detailCell As GridDetailViewCellElement = TryCast(e.CellElement, GridDetailViewCellElement)
    If detailCell IsNot Nothing Then
        For i As Integer = 0 To detailCell.PageViewElement.Items.Count - 1
            RemoveHandler detailCell.PageViewElement.ItemSelected, AddressOf PageViewElement_ItemSelected
            AddHandler detailCell.PageViewElement.ItemSelected, AddressOf PageViewElement_ItemSelected
        Next
    End If
End Sub
 
Private Sub PageViewElement_ItemSelected(sender As Object, e As RadPageViewItemSelectedEventArgs)
    If TryCast(sender, RadPageViewStripElement).Items.IndexOf(e.SelectedItem) = 1 Then
        TryCast(TryCast(sender, RadPageViewStripElement).Parent, GridDetailViewCellElement).ChildTableElement.RowHeight = 120
    Else
        TryCast(TryCast(sender, RadPageViewStripElement).Parent, GridDetailViewCellElement).ChildTableElement.RowHeight = 24
    End If
End Sub

I was hoping that one wouldn't have to do this manually (setting the height) because one never really knows the actual height of any given row result.

Once again, I apologize if I posted this in the wrong area, but the title grabbed my attention and I made the post accordingly.

I hope this helps clarifies things one way or the other.

ADMIN
Stefan
Posted on: 06 Mar 2014 06:56
Hi Martin,

I am having difficulties understanding what is the issue you experience and what is it that you need. May I please ask you to open a new support ticket with detailed explanation of the experiences issue and the desired behavior. Perhaps you can also include a sample where we can see it. 

Thank you in advance for your time and cooperation.
Martin Hamilton
Posted on: 06 Mar 2014 01:56
I know it's difficult to account for the font, etc to determine row height, but even if you get close to the right height - if you put in properties for padding type of thing - we'll be able to adjust that ourselves.  But if possible - this is really important as right now we need to use a 'time-consuming' event in the gridview to do this... and even that is difficult because if it's a variable length value and therefore the height is variable - it's difficult to do right now manually/programmatically.