GridViewDataColumn Width = "Auto" is not working

5 posts, 0 answers
  1. Xinfeng
    Xinfeng avatar
    15 posts
    Member since:
    Jul 2011

    Posted 16 Aug 2011 Link to this post

    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
     
     
  2. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 17 Aug 2011 Link to this post

    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 >>

  3. Xinfeng
    Xinfeng avatar
    15 posts
    Member since:
    Jul 2011

    Posted 17 Aug 2011 Link to this post

    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 
  4. Vanya Pavlova
    Admin
    Vanya Pavlova avatar
    2019 posts

    Posted 02 Sep 2011 Link to this post

    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 >>

  5. Xinfeng
    Xinfeng avatar
    15 posts
    Member since:
    Jul 2011

    Posted 02 Sep 2011 Link to this post

    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
Back to Top