Column width ignored inside DataTemplate

13 posts, 0 answers
  1. Terry
    Terry avatar
    4 posts
    Member since:
    Jan 2011

    Posted 26 Jan 2011 Link to this post

    I am using RadGridView inside a DataTemplate in RadTabControl. However, the Width property in GridViewDataColumn is completely ignored and appeared to be set to Auto.

    What I am trying to achieve is that I want the column to take up the remaining space by using Width="*" and the context I am using it is in RadTabControl.


    Here is the code - comparing RadGridView outside DataTemplate, DataGrid, and RadGridView inside DataTemplate.
    Here is the result -
    RadGridView outside DataTemplate : The * works as expected and take up the remaining grid space.
    DataGrid inside DataTemplate : The * works as expected and take up the remaining grid space.
    RadGridView inside DataTemplate: The * is ignored and does not work. I have tried to use a specific number like 200 and it is ignored as well.

    Is this a bug in how the Width is being handled?

    Please assist.
    Thanks,
    Terry



    <telerikGrid:RadGridView AutoGenerateColumns="False" Grid.Row="3">
        <telerikGrid:RadGridView.Columns>
            <telerikGrid:GridViewDataColumn Header="Name" Width="*" />
        </telerikGrid:RadGridView.Columns>
    </telerikGrid:RadGridView>
     
    <ListView Grid.Row="1" ItemsSource="{Binding Selections}">
        <ListView.ItemTemplate>
            <DataTemplate>
                <StackPanel>
                    <DataGrid AutoGenerateColumns="False">
                        <DataGrid.Columns>
                            <DataGridTextColumn Header="name" Width="*" />
                        </DataGrid.Columns>
                    </DataGrid>
                <telerikGrid:RadGridView AutoGenerateColumns="False">
                    <telerikGrid:RadGridView.Columns>
                        <telerikGrid:GridViewDataColumn Header="Name" Width="*" />
                    </telerikGrid:RadGridView.Columns>
                </telerikGrid:RadGridView>
                </StackPanel>
            </DataTemplate>
        </ListView.ItemTemplate>
    </ListView>

  2. Yordanka
    Admin
    Yordanka avatar
    634 posts

    Posted 28 Jan 2011 Link to this post

    Hello Terry,

    Thank you for the feedback.

    We will investigate the issue and we will contact you as soon as we have more information.
     
    Best wishes,
    Yordanka
    the Telerik team
    Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
  3. UI for WPF is Visual Studio 2017 Ready
  4. anthony
    anthony avatar
    4 posts
    Member since:
    Jan 2011

    Posted 01 Feb 2011 Link to this post

    I am having the same issue.  For me, it is because the Column is set (by default I think) to be the header width (in the IDE ColumnWidth is set to SizeToHeader). If I set the header width it in fact grows the column with it.  What I am not sure about is the proper way to get the column sized iteself (and then perhaps grow the header accordingly?)
  5. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 07 Feb 2011 Link to this post

    Hello Terry,

     Please set ColumnWidth="*" for RadGridView to avoid this. Generally SizeToHeader will size the cells according to the column header and SizeToCells will size the cells according the cells content. 

    Kind regards,
    Vlad
    the Telerik team
    Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
  6. Hrachya Bekverdyan
    Hrachya Bekverdyan avatar
    1 posts
    Member since:
    Feb 2010

    Posted 16 Mar 2011 Link to this post

    Hi
    I have the same problem.
    I don't want to use the ColumnWidth property of RadGridView. Because I want to set fixed width.
    Are there another way?
    And I can't find SizeToHeader and SizeToCells  properties, how we can use them?

    Please help me.
    Thanks.
  7. Avi Avni
    Avi Avni avatar
    98 posts
    Member since:
    Feb 2010

    Posted 23 May 2011 Link to this post

    Hello

    We have problem with the width columns.

    When the view load there is jump in the grid columns.

    After this the columns are arranged well.

    is someone having a similar problem?


    Best regards

    Ehud

  8. LHR
    LHR avatar
    16 posts
    Member since:
    Apr 2011

    Posted 26 Jul 2011 Link to this post

    It took me forever to track down your post and realize that this was a bug with Telerik's RadGridView. I am surprised they haven't fixed this yet.

    I have the same issue. A RadGridView inside of a DataTemplate ignores the individual Column Widths. This is important for me since the column text is supposed to wrap, and I cannot wrap the text if the column width is set to Auto.

    I moved my RadGridView out of my DataTemplate, but I am not happy with this solution. Please fix it soon.

  9. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 28 Jul 2011 Link to this post

    Hello Lhr,

     Indeed you are right, we are aware of this behavior. Still we meet some unexpected behavior of the Framework and we are not able to provide a permanent solution. It has been logged at our Public tracking system under PITS ID 4796, where you may follow its progress. 

    Kind regards,
    Didie
    the Telerik team

    Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

  10. Thomas
    Thomas avatar
    28 posts
    Member since:
    Jun 2010

    Posted 14 Mar 2012 Link to this post

    Hi,

    i have a similar problem. I am using the Q1 2011 Version. It seems that you can't set a "custom" header within a datatemplate.

    Example:

    <telerik:GridViewDataColumn  DataMemberBinding="{Binding Path=BlockName}" >
       <telerik:GridViewDataColumn.Header>
          <StackPanel>
               <TextBlock Text="Simulating a" />
               <TextBlock Text="MultiLine" />
          </StackPanel>
       </telerik:GridViewDataColumn.Header>
    </telerik:GridViewDataColumn>

    Within a DataTemplate you see the header "BlockName". This works without using a datatemplate. Is there a workarround for my version?

    Thanks and Regards,
    Thomas

  11. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 15 Mar 2012 Link to this post

    Hi,

     The Header of the GridViewDataColumn is an object, it is not a DataTemplate. That is why you cannot set a "custom" header within a datatemplate.  

    Regards,
    Didie
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
  12. Thomas
    Thomas avatar
    28 posts
    Member since:
    Jun 2010

    Posted 15 Mar 2012 Link to this post

    So why works this with the newest telerik binaries? Is a GridViewDatacolumn ot an object too? Do you have hint for me to solve my problem?

    <DataTemplate x:Key="MonthTemplate">
      <telerik:RadGridView ItemsSource={Binding Path=xxx}>
       <telerik:RadGridView.Columns>
          <telerik:GridViewDataColumn  DataMemberBinding="{Binding Path=BlockName}" >
               <telerik:GridViewDataColumn.Header>
                   <StackPanel>
                       <TextBlock Text="Simulating a" />
                       <TextBlock Text="MultiLine" />
                  </StackPanel>
              </telerik:GridViewDataColumn.Header>
           </telerik:GridViewDataColumn>
    ...

    Regards,
    Thomas
  13. Svyazhikova
    Svyazhikova avatar
    1 posts
    Member since:
    Sep 2013

    Posted 15 Jul 2015 Link to this post

    Where can I see current bug progress? Link http://www.telerik.com/support/pits.aspx#/public/wpf/4796 is broken.
  14. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 15 Jul 2015 Link to this post

    Hi,

    As it turns out this is a very old issue (logged back in 2011).

    If you have encountered a similar one and it is blocking for your work, then would it be possible for you to isolate it in a demo project and send it to us in a new support ticket? You can also take a look at this blog post for a reference on how to isolate an issue. 

    That way we will review the specific case and advice further.

    Regards,
    Dimitrina
    the Telerik team
     
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
     
Back to Top
UI for WPF is Visual Studio 2017 Ready