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

[Solved] Making a Gridview the height of its container

10 Answers 400 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.
Terry
Top achievements
Rank 1
Terry asked on 29 Sep 2009, 01:15 AM
I have a UserControl that consists of a radGridVeiw inside of a Grid cell.  If I don't specify the height or if I specify "Auto", the grid takes takes minutes to render (there are 1000's of rows).  if I specify a height, the rendering is fast (since only the visible rows are rendered), but the grid is too small or too large depending upon the size of the user's screen.  Is there a way I can make the radGridView the same size as its containing grid cell (or any other container that would work better) without creating a long delay?

I tried setting the height to the grid's height in the Loaded event, but the debugger says the value is "NaN", which I presume means not a number. 

Thanks,

Terry

10 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 01 Oct 2009, 02:59 PM
Hello Terry,

If the grid is measured with infinity (or large height) you will get serious performance problems since RadGridView will try to create all rows - no virtualization in this case.

Kind regards,
Vlad
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.
0
Terry
Top achievements
Rank 1
answered on 01 Oct 2009, 07:15 PM
Hi Vlad:

I don't want an infinite height, I just want the same height as the grid cell the control is sitting in.  In the old days, I'd just set control.Height = container.Height, but I can't make that work.
0
Vlad
Telerik team
answered on 02 Oct 2009, 05:50 AM
Hello Terry,

The grid does not have any default value for Height and will occupy by default all available space. Can you post an example where RadGridView does not work properly?

Sincerely yours,
Vlad
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.
0
Terry
Top achievements
Rank 1
answered on 07 Oct 2009, 11:03 PM
Hi Vlad:

In the following XAML, I want Report_Grid to size itself to the size of it's container, which is the second row of the grid.  I've set it to 500 on my development machine, which is close for me, but the grid cell could be most any height on a user machine.  And even on one machine it can change because of my use of your Docking control   If I don't set a height, that works, but the gridview virtualizes and takes a couple of minutes to populate.  Setting the height to LayoutRoot.Height in the Loaded event doesn't work.

<UserControl   
    x:Class="KPIControl.ReportGrid" 
    xmlns:radGridView="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.GridView"    
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"   
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"   
    Loaded="UserControl_Loaded" > 
    <Grid x:Name="LayoutRoot" Background="White">  
        <Grid.RowDefinitions> 
            <RowDefinition Height=".05*" /> 
            <RowDefinition Height="1*" /> 
        </Grid.RowDefinitions> 
        <TextBlock x:Name="Report_Heading" Text="Heading" FontSize="16" FontWeight="Bold" HorizontalAlignment="Center" Grid.Row="0"/>  
        <radGridView:RadGridView x:Name="Report_Grid" Width="Auto" Height="500"  AutoGeneratingColumn="Report_Grid_AutoGeneratingColumn" 
                                 Grid.Row="1"   
                                 ColumnsWidthMode="Auto" ScrollViewer.HorizontalScrollBarVisibility="Auto" 
                                 ScrollViewer.VerticalScrollBarVisibility="Auto" ScrollMode="Deferred" 
                                 > 
        </radGridView:RadGridView> 
    </Grid> 
</UserControl> 
 


0
Krlos
Top achievements
Rank 1
answered on 09 Oct 2009, 11:16 PM
Hi Terry

I am searching for exactly the same, a grid inside a dock. Because of the problem you have with the performance. I found this link, it might be useful.
http://blogs.telerik.com/valerihristov/posts/09-05-18/gridview_in_combobox_with_radcontrols_for_silverlight.aspx
0
Vlad
Telerik team
answered on 12 Oct 2009, 07:11 AM
Hello Terry,

I've attached small application to illustrate you how to achieve your goal - you can simply remove Height from the grid.

Kind regards,
Vlad
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.
0
Terry
Top achievements
Rank 1
answered on 12 Oct 2009, 03:50 PM
But if I remove the height from the grid, per your previous post:

"If the grid is measured with infinity (or large height) you will get serious performance problems since RadGridView will try to create all rows - no virtualization in this case."

When I do this, the user waits approximately 2 minutes for the grid to render.

So I can't use an infinite height, I need to set the height to the height of the container.  Can you assist me in doing that?

Thanks,

Terry
0
Terry
Top achievements
Rank 1
answered on 12 Oct 2009, 04:17 PM
Thanks, Krlos.

I'm hoping I won't have to resort to a control template and templatebinding to simly set the height of a grid, but if I do, your post is extremely helpful.

Terry
0
Vlad
Telerik team
answered on 13 Oct 2009, 05:43 AM
Hi Terry,

Removing Height from this configuration will not measure the grid with infinity. This can happen if the grid is inside StackPanel or ScrollViewer.

Best wishes,
Vlad
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.
0
Terry
Top achievements
Rank 1
answered on 13 Oct 2009, 03:52 PM
You are right.  I thought specifying no height was the same as infinity.  I was getting the performance hit because, in my latest experiment, my radGridView was inside a stackpanel.  I changed the container back to a grid, removed the height from the radGridView, and everything worked as advertised.

Sorry for being so dense on this issue.

Terry
Tags
GridView
Asked by
Terry
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Terry
Top achievements
Rank 1
Krlos
Top achievements
Rank 1
Share this question
or