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

Column width ignored inside DataTemplate

12 Answers 117 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Terry
Top achievements
Rank 1
Terry asked on 26 Jan 2011, 11:35 PM
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>

12 Answers, 1 is accepted

Sort by
0
Yordanka
Telerik team
answered on 28 Jan 2011, 02:24 PM
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>>
0
anthony
Top achievements
Rank 1
answered on 01 Feb 2011, 11:04 PM
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?)
0
Vlad
Telerik team
answered on 07 Feb 2011, 03:45 PM
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>>
0
Hrachya Bekverdyan
Top achievements
Rank 1
answered on 16 Mar 2011, 02:04 PM
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.
0
Avi Avni
Top achievements
Rank 1
answered on 23 May 2011, 01:46 PM

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

0
LHR
Top achievements
Rank 1
answered on 26 Jul 2011, 01:47 PM
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.

0
Dimitrina
Telerik team
answered on 28 Jul 2011, 03:14 PM
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!

0
Thomas
Top achievements
Rank 1
answered on 14 Mar 2012, 05:14 PM
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

0
Dimitrina
Telerik team
answered on 15 Mar 2012, 11:09 AM
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 >>
0
Thomas
Top achievements
Rank 1
answered on 15 Mar 2012, 01:34 PM
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
0
Svyazhikova
Top achievements
Rank 1
answered on 15 Jul 2015, 05:56 AM
Where can I see current bug progress? Link http://www.telerik.com/support/pits.aspx#/public/wpf/4796 is broken.
0
Dimitrina
Telerik team
answered on 15 Jul 2015, 01:58 PM
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 >>
 
Tags
GridView
Asked by
Terry
Top achievements
Rank 1
Answers by
Yordanka
Telerik team
anthony
Top achievements
Rank 1
Vlad
Telerik team
Hrachya Bekverdyan
Top achievements
Rank 1
Avi Avni
Top achievements
Rank 1
LHR
Top achievements
Rank 1
Dimitrina
Telerik team
Thomas
Top achievements
Rank 1
Svyazhikova
Top achievements
Rank 1
Share this question
or