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

Q3 - Relative Column Width No Longer Working

2 Answers 59 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Shannon Marsh
Top achievements
Rank 1
Shannon Marsh asked on 30 Nov 2009, 04:30 AM
Hi,

We have several RadGridViews set up with manually defined columns.  Our column widths were defined to support relative sizing, ie Width="20*".  ColumnWidthMode for the grid was set to "Fill".  The reason for this was that we did not want certain fields to wasting space.  For example in the example below the "Date of Birth" and "Licence Number" are only narrow columns allowing for the other columns to take up more space. 

After installing the Q3 release all the columns appear on screen with the same width, ignoring the column widths that we have defined.  I don't want to change the columns to be fixed width as this will cause problems on different sized screens and/or when user resizes the window.  Is there anything we can do to get this functionality back?

Here is the XAML for the column definitions from one of our grids.
<telerik:RadGridView.Columns> 
                        <telerik:GridViewDataColumn Header="Name" 
                                                    DataMemberBinding="{Binding PersonDetails}" 
                                                    Width="35*" 
                                                    IsFilterable="False" 
                                                    ShowDistinctFilters="False"/>  
                        <telerik:GridViewDataColumn Header="D.O.B." 
                                                    DataMemberBinding="{Binding BirthDate}" 
                                                    Width="15*" 
                                                    ShowDistinctFilters="False"/>  
                        <telerik:GridViewDataColumn Header="Address" 
                                                    DataMemberBinding="{Binding ResidentialAddress}" 
                                                    Width="35*" 
                                                    ShowDistinctFilters="False"/>  
                        <telerik:GridViewDataColumn Header="Licence Number" 
                                                    DataMemberBinding="{Binding LicenceNumbers}"   
                                                    Width="15*" 
                                                    ShowDistinctFilters="False"/>  
                    </telerik:RadGridView.Columns> 



2 Answers, 1 is accepted

Sort by
0
Shannon Marsh
Top achievements
Rank 1
answered on 02 Dec 2009, 03:39 AM
Hi,

Just an update on this.  I have found that this only happens when the GridView is part of a datatemplate being presented in a ContentPresenter.  Unfortunately I cannot work around this because the template needs to be displayed for specific data types.

I have attached an example that demonstrates the problem.

Any ideas?

<Window x:Class="TelerikQ3RadGridTesting.Window1" 
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
        xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation" 
        Title="Window1">  
    <Window.Resources>          
        <DataTemplate x:Key="MyDataTemplate">  
            <StackPanel HorizontalAlignment="Stretch" > 
                <telerik:RadGridView x:Name="TestGrid" 
                             ItemsSource="{Binding Things}" 
                             AutoGenerateColumns="False" 
                             ColumnsWidthMode="Fill" 
                             ShowGroupPanel="False" 
                             > 
                    <telerik:RadGridView.Columns> 
                        <telerik:GridViewDataColumn Header="Test Data Column" 
                                            DataMemberBinding="{Binding field1}" 
                                            Width="10*">  
                        </telerik:GridViewDataColumn> 
                        <telerik:GridViewDataColumn Header="Test Column" 
                                            DataMemberBinding="{Binding field2}" 
                                            Width="80*">  
                        </telerik:GridViewDataColumn> 
                        <telerik:GridViewDataColumn Header="Test Column" 
                                            DataMemberBinding="{Binding field3}" 
                                            Width="30*">  
                        </telerik:GridViewDataColumn> 
                    </telerik:RadGridView.Columns> 
                </telerik:RadGridView> 
            </StackPanel> 
        </DataTemplate> 
    </Window.Resources> 
    <StackPanel> 
        <ContentPresenter Content="{Binding}"   
                          ContentTemplate="{StaticResource MyDataTemplate}" 
                          SnapsToDevicePixels="True"/>  
 
        <telerik:RadGridView x:Name="TestGrid" 
                             ItemsSource="{Binding Things}" 
                             AutoGenerateColumns="False" 
                             ColumnsWidthMode="Fill" 
                             ShowGroupPanel="False" 
                             > 
            <telerik:RadGridView.Columns> 
                <telerik:GridViewDataColumn Header="Test Data Column" 
                                            DataMemberBinding="{Binding field1}" 
                                            Width="10*">  
                </telerik:GridViewDataColumn> 
                <telerik:GridViewDataColumn Header="Test Column" 
                                            DataMemberBinding="{Binding field2}" 
                                            Width="80*">  
                </telerik:GridViewDataColumn> 
                <telerik:GridViewDataColumn Header="Test Column" 
                                            DataMemberBinding="{Binding field3}" 
                                            Width="30*">  
                </telerik:GridViewDataColumn> 
            </telerik:RadGridView.Columns> 
        </telerik:RadGridView> 
    </StackPanel> 
    </Window> 
 
0
Nedyalko Nikolov
Telerik team
answered on 03 Dec 2009, 09:13 AM
Hi Shannon Marsh,

Generally if you want to use such relative sizing functionality you should avoid using StackPanel and ScrollViewer since these UI elements measure all child controls with infinity and RadGridView automatically changes all "*" column into an "auto" columns. You can check this sticky thread for more details.

All the best,
Nedyalko Nikolov
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
Shannon Marsh
Top achievements
Rank 1
Answers by
Shannon Marsh
Top achievements
Rank 1
Nedyalko Nikolov
Telerik team
Share this question
or