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

ColumnGroup text not wrapping automatically

3 Answers 246 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Nemanja
Top achievements
Rank 1
Nemanja asked on 25 Jan 2012, 01:37 PM
Hi,

I've implemented the ColumnGroups feature on a grid and it works well enough, but I'm running into a problem when the header of the column group exceeds the width of the actual group and it runs over the borders instead of wrapping onto a new line.

There isn't much documentation available on the ColumnGroups as far as I can see, so I'm not sure how we can get around that? Is there a style setting that we can use in the HeaderStyle or is there another way to do it?

Thanks,
Nemanja

3 Answers, 1 is accepted

Sort by
0
Pavel Pavlov
Telerik team
answered on 30 Jan 2012, 12:51 PM
Hello Nemanja,

Here is how you can achive the desired result . The important code is in yellow.
<telerik:RadGridView >
            <telerik:RadGridView.ColumnGroups>
                <telerik:GridViewColumnGroup Name="Group1" Header="Lorem Ipsum Dolor sin amet">
                    <telerik:GridViewColumnGroup.HeaderTemplate>
                        <DataTemplate>
                            <TextBlock Text="{Binding }"  TextWrapping="Wrap" />
                        </DataTemplate>
                    </telerik:GridViewColumnGroup.HeaderTemplate>
                </telerik:GridViewColumnGroup>
                <telerik:GridViewColumnGroup Name="Group2" Header="Group2"/>
            </telerik:RadGridView.ColumnGroups>
            <telerik:RadGridView.Columns>
                <telerik:GridViewColumn Width="50" ColumnGroupName="Group1" />
                <telerik:GridViewColumn Width="50" ColumnGroupName="Group1" />
                <telerik:GridViewColumn ColumnGroupName="Group2" />
                <telerik:GridViewColumn ColumnGroupName="Group2" />
            </telerik:RadGridView.Columns>
        </telerik:RadGridView>

Please be sure to use the latest dlls (the ones from our latest internal build ) as they contain some relevant fixes.

I am attaching a runnable project with the code above as well


Greetings,
Pavel Pavlov
the Telerik team

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

0
Nemanja
Top achievements
Rank 1
answered on 30 Jan 2012, 01:12 PM
Hi Pavel,

Thanks for this, that's exactly what I was looking for. The only issue now is that we have a global style throughout our application that applies to all column header groups. How would one put that template in the style? The CommonColumnHeader doesn't have a HeaderTemplate property.

Here is the style we have at present, how do we add the text wrap option to it?

<Style x:Key="RadGridViewHeaderGroupStyle" TargetType="{x:Type rad:CommonColumnHeader}">
        <Setter Property="HorizontalContentAlignment" Value="Center" />
        <Setter Property="BorderThickness" Value ="0,0,1,1"/>
        <Setter Property="BorderBrush" Value ="#FF83A5D2"/>
        <Setter Property="Background">
            <Setter.Value>
                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                    <GradientStop Color="#FFEBF3FF" Offset="0"/>
                    <GradientStop Color="#FFD0E8FF" Offset="1"/>
                    <GradientStop Color="#FFABC9EE" Offset="0.43"/>
                    <GradientStop Color="#FFC6DFFF" Offset="0.42"/>
                </LinearGradientBrush>
            </Setter.Value>
        </Setter>      
    </Style>
0
F Beto
Top achievements
Rank 1
answered on 05 Sep 2013, 06:48 PM
Hello Pavel,

I have a almost the same problem but with GridViewHyperlinkColumn, TextWrapping="Wrap" doesn't work!
I have attached an image. Could you help me? I am using Telerik controls 2013 Q1

Thanks in advance.
Tags
GridView
Asked by
Nemanja
Top achievements
Rank 1
Answers by
Pavel Pavlov
Telerik team
Nemanja
Top achievements
Rank 1
F Beto
Top achievements
Rank 1
Share this question
or