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

[Solved] GridViewDataColumn Width = "Auto" is not working

4 Answers 473 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.
Xinfeng
Top achievements
Rank 1
Xinfeng asked on 16 Aug 2011, 04:43 PM
Hi,

I have the following RadGridView code:
<Grid x:Name="LayoutRoot">
      <telerikNavigation:RadTabControl BorderThickness="0" Style="{StaticResource StandardTabStyle}">       
            <telerikNavigation:RadTabItem Header="Projected Cash Balance" Style="{StaticResource StandardTabItemStyle}">
                <Border Grid.Column="0" Style="{StaticResource PanelBody}" BorderThickness="0" HorizontalAlignment="Stretch" >
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="*" />
                        </Grid.RowDefinitions>
 
                        <Border Style="{StaticResource PanelStrip}" BorderThickness="0,0,0,1" Grid.Row="0">
                            <StackPanel Orientation="Horizontal" HorizontalAlignment="Left">
                                <TextBlock Text="Settle Date:" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0 0 5 0" />
                                <Controls:RadDatePicker SelectedDate="{Binding SettleDate, Mode=TwoWay}" MinWidth="100" />
                            </StackPanel>
                        </Border>
 
                        <telerikGridView:RadGridView Grid.Row="1"
                            x:Name="cashProjectionView"
                            Style="{StaticResource StandardRadGridView}"
                            ItemsSource="{Binding CashProjectionItems}"
                            SelectionMode="Extended"
                            SelectionUnit="Cell"
                            ClipboardCopyMode="Cells"
                            AutoGenerateColumns="False"
                            ShowColumnFooters="True"
                            EnableRowVirtualization="True"
                            EnableColumnVirtualization="False">
 
                            <i:Interaction.Behaviors>
                                <GridView:RadGridViewAutoFormat/>
                                <Toolbar:RadGridViewToolbar/>
                                <GridView:RadGridTotalLabel/>
                                <!--<GridView:RadGridViewRealTime EventName="CashMgmt"/>-->
                            </i:Interaction.Behaviors>
                            <telerikGridView:RadGridView.Columns>
                                <telerikGridView:GridViewDataColumn Header="Account" DataMemberBinding="{Binding acctNbr}" Width="Auto"/>
                                <telerikGridView:GridViewDataColumn Header="Currency" DataMemberBinding="{Binding ccy}" Width="Auto"/>
                                <telerikGridView:GridViewDataColumn Header="Know Date" DataMemberBinding="{Binding knowDate}" Width="Auto"/>
                                <telerikGridView:GridViewDataColumn Header="SD1 Value" DataMemberBinding="{Binding SD1Value}" Width="Auto"/>
                                <telerikGridView:GridViewDataColumn Header="SD2 Value" DataMemberBinding="{Binding SD2Value}" Width="Auto"/>
                                <telerikGridView:GridViewDataColumn Header="SD3 Value" DataMemberBinding="{Binding SD3Value}" Width="Auto"/>
                                <telerikGridView:GridViewDataColumn Header="TD Value" DataMemberBinding="{Binding tdValue}" Width="Auto"/>
                            </telerikGridView:RadGridView.Columns>
 
                            <telerikGridView:RadGridView.SortDescriptors>
                                <Data:SortDescriptor Member="Account" SortDirection="Ascending"/>
                            </telerikGridView:RadGridView.SortDescriptors>
                        </telerikGridView:RadGridView>
                    </Grid>
                </Border>
            </telerikNavigation:RadTabItem>
        </telerikNavigation:RadTabControl>
    </Grid>

I am populating the GridView asynchronously using WCF Web Service and Rx. However, the column width is not set automatically after the GridView is populated with data. Anything wrong with my settings? (I am using Q2 2011)

Thanks a lot!

Xinfeng
 
 

4 Answers, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 17 Aug 2011, 07:17 AM
Hi Xinfeng,

The default value for each column's Width property is "Auto", so generally you do not need to set it explicitly. May you clarify what is the exact behavior that you experience, how are the columns sized ?
 

Greetings,
Maya
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

0
Xinfeng
Top achievements
Rank 1
answered on 17 Aug 2011, 01:49 PM
Hi Maya,

The width of each column was not automatically adjusted to the width of the value inside (I guess it had something to do with the Asynchronize call to populate the Grid), which was why I set the "Auto" manually. However, it was still not working, many of the values were truncated. What I am doing now is I set a width for each column in this GridView.

Thanks a lot!

Xinfeng 
0
Vanya Pavlova
Telerik team
answered on 02 Sep 2011, 07:59 AM
Hi Xinfeng,

 

I have already replied to your support ticket.
For those who might be interested in your case I am pasting the answer here for further reference:


As my colleague Maya proposed the Width property of a column is set to Auto. 
The possible values, which may be assigned to this property are described in the following thread, please follow this link. As you noticed you may also set this property to SizeToCells value where the Width of the column is equal to to the width of the widest (excluding header) cell.



Greetings,
Vanya Pavlova
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

0
Xinfeng
Top achievements
Rank 1
answered on 02 Sep 2011, 03:45 PM
Hi Vanya,

The "SizeToCells" is not working. I am populating the GridView asynchronously using WCF web service and I am using Prism. 

Thanks a lot!

Xinfeng
Tags
GridView
Asked by
Xinfeng
Top achievements
Rank 1
Answers by
Maya
Telerik team
Xinfeng
Top achievements
Rank 1
Vanya Pavlova
Telerik team
Share this question
or