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

[Solved] Grid Height and ScrollBars

1 Answer 173 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Tim
Top achievements
Rank 1
Tim asked on 23 Sep 2009, 02:03 PM
I was hoping SL3/812 would correct this problem as well, but it hasn't.  I would like to have a series of GridViews which are a minimum height when the bound collection is empty, grow 1 row at a time up to some maximum height, and then start scrolling.  The only way so far to get the scrollbar to appear is to set the GridView's MaxHeight property.  Whenever I do this and the bound collection is empty, the grid sizes to MaxHeight and looks ugly.  For 1, 2, 3...10 rows, it sizes properly and then starts scrolling, but quite often the collection is legitimately empty.

The GridViews themselves are all inside a Grid inside a RadExpander inside a larger grid, etc., like so:

<Telerik:RadExpander Grid.Row="3" Grid.Column="0" x:Name="Events"  
  IsExpanded="True" Header="{Binding Path=Resource.Events, Source={StaticResource i18n}}"
  <Grid> 
    <Grid.RowDefinitions> 
      <RowDefinition Height="auto"/> 
    <Grid.RowDefinitions> 
    <Grid.ColumnDefinitions> 
      <ColumnDefinition Width="*"/> 
    </Grid.ColumnDefinitions> 
    <TelerikGridView:RadGridView  
      x:Name="EventViewer" Grid.Row="0" IsReadOnly="True" 
      MaxHeight="400" ScrollMode="RealTime" 
      AutoGenerateColumns="False" > 
 

I've tried setting the Grid.Row Height to *, and 400 as well and left off the MaxHeight on the RadGridView and that did nothing -- in that case, and the no MaxHeight on RadGridView case the grid fills up as many rows as there are.  I also set the MinHeight hoping that would be respected when empty - to no avail.

Thx,
Tim

1 Answer, 1 is accepted

Sort by
0
Hristo
Telerik team
answered on 26 Sep 2009, 06:53 AM
Hello Tim,

The default behavior of RadGridView is to fill all available space even if there are no row/columns.
This is controlled by HorizntalAlignment and VerticalAlignment. If you want RadGridView Height to be based on rows count (and not to take all available height) you should set VerticalAlignment="Top". Also if you want to be no more the some specific height you can set MaxHeight like you did in your code.

Let me know if you need more help.

Kind regards,
Hristo
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
GridView
Asked by
Tim
Top achievements
Rank 1
Answers by
Hristo
Telerik team
Share this question
or