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

How to change the Header Label

9 Answers 430 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Marco
Top achievements
Rank 1
Marco asked on 26 Jan 2009, 02:46 PM
Hi,
how to change the label in  RadGridView "Drag a Column header and drop it here to group by that colunm" ?

Thanks.
Marco

9 Answers, 1 is accepted

Sort by
0
Pavel Pavlov
Telerik team
answered on 27 Jan 2009, 05:45 PM

Hello Marco,

To achieve this you need to provide a custom template for the GridViewGroupPanel element.

Here is some sample xaml:

<Grid> 
        <Grid.Resources> 
            <Style TargetType="telerik:GridViewGroupPanel">  
                <Setter Property="Template">  
                    <Setter.Value> 
                        <ControlTemplate  TargetType="telerik:GridViewGroupPanel">  
                            <Grid Background="Transparent">  
                                <Border HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Opacity="0.6" /> 
                                <Border HorizontalAlignment="Stretch" VerticalAlignment="Stretch" /> 
                                <WrapPanel Margin="-2,0,0,0">  
                                    <ItemsPresenter x:Name="itemsPresenter" Margin="0,10,10,0" /> 
                                </WrapPanel> 
                                <TextBlock Text="Modified text goes here..." Margin="10, 0, 0, 0"  IsHitTestVisible="False" VerticalAlignment="Center"  /> 
                            </Grid> 
                        </ControlTemplate> 
                    </Setter.Value> 
                </Setter> 
            </Style> 
        </Grid.Resources> 
...

Here I have added a style for the GridViewGroupPanel. The style is added to the resources of the root element of my window. It sets the template of the GridViewGroupPanel to a custom one (with modified text).

Greetings,

Pavel Pavlov
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Jérôme Gaborieau
Top achievements
Rank 1
answered on 15 Jul 2009, 03:26 PM
Hello Pavel,

When I use your code and when I group by a column, the rectangle containing the column have a transparent background.
The problem is I don't see the column name, it's confused with the "TextBlock". How I can do?

Thanks

P.S. : Sorry for English, I'm French !
0
Pavel Pavlov
Telerik team
answered on 17 Jul 2009, 11:35 AM

Hello Jérôme Gaborieau,

I am not sure what exactly is the trouble. I guess both texts overlap and make caption unreadable ? .

In such case I would recommend to set margins to the textblock in the template provided , so that the text is moved up or down and thus stop overlapping with the items.

<TextBlock Text="Modified text goes here..." Margin="10, 0, 0, 0" ...

Here you can try setting different values of the margins. Hope this will fix the problem.

Kind regards,

Pavel Pavlov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Jérôme Gaborieau
Top achievements
Rank 1
answered on 17 Jul 2009, 11:57 AM
Thank you for the answer,

But, can I change the background color of the column's name or hide the text when I sort by a column?

Thanks

Jérôme
0
Pavel Pavlov
Telerik team
answered on 17 Jul 2009, 12:05 PM
Hi Jérôme ,

I guess you are trying to localize the RadGridView ?

When localized , this text will hide automatically . Here is a detailed description on how you can localize the RadGridView texts ( including the Group Header) .


All the best,
Pavel Pavlov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Byron
Top achievements
Rank 1
answered on 12 Nov 2009, 02:58 PM
Hi, I like this post, it has helped me. I have a question, I would like to put a checkbox on the GridViewGroupPanel,,,,which I've already done. Can I bind that checkbox and property IsFilteringAllowed on the RadGridView? What I'd like to be able to do is turn on/off Filtering on the fly....Can that even be done? 

 I'm looking at adding this to the ControlTemplate inside a Resource dictionary and implement with XAML binding that way the individual UI's don't have to be touched, that way I can add the ability for the users to turn on/off filtering as they wish so that I can conserved the space taken up by the filtering Icon (LOTS of columns on some grids).

In this case, by default my RadGridView Style is setting IsFilteringAllowed = False and I'd like to bind the checkbox on the GridViewGroupPanel and this property to that on property changed I could turn on filtering???? (At least that's my hope....)

Byron
0
Pavel Pavlov
Telerik team
answered on 17 Nov 2009, 05:17 PM
Hello Byron,
It is absolutely possible!
Please have a look at the attached project.

In case you have troubles adapting this to your scenario just let me know.

Best wishes,
Pavel Pavlov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
jas
Top achievements
Rank 1
answered on 08 Mar 2010, 05:10 PM

Thank you for the example code, which I have copied into my project. But, whilst the default text "Group header etc" is replaced by "Grouped by:" when you drag a column header to the panel, with your example this is not the case, and the column label is ovelapping the new header text which is not replaced by anything else such as "Group by:"

How can I make the customised text dispapear when you are grouping - just like it does by default?
Here is my xaml:

    <Style TargetType="telerik:GridViewGroupPanel">  
      <Setter Property="Template">  
        <Setter.Value> 
          <ControlTemplate  TargetType="telerik:GridViewGroupPanel">  
            <Grid Background="Transparent">  
              <Border HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Opacity="0.6" /> 
              <Border HorizontalAlignment="Stretch" VerticalAlignment="Stretch" /> 
              <WrapPanel Margin="-2,0,0,0">  
                <ItemsPresenter x:Name="itemsPresenter" Margin="0,20,3,0" /> 
              </WrapPanel> 
              <StackPanel Orientation="Vertical" Margin="10,10,0,0" > 
                <TextBlock Text="Logged Events" FontFamily="Times New Roman" FontSize="20" IsHitTestVisible="False" VerticalAlignment="Center"  /> 
                <TextBlock Text="Drag a column header and drop it here to group by that column" Opacity="0.5" FontFamily="Arial" FontSize="10" IsHitTestVisible="False" VerticalAlignment="Center"  /> 
              </StackPanel> 
            </Grid> 
          </ControlTemplate> 
        </Setter.Value> 
      </Setter> 
    </Style> 
 


Thanks (using 2009 Q3 SP2)

James.

0
Pavel Pavlov
Telerik team
answered on 11 Mar 2010, 10:47 AM
Hello jas,

I have added a <ControlTemplate.Triggers>  section to your XAML in order to have the two texts hiding when there are items in the GroupPanel.

<Style TargetType="telerik:GridViewGroupPanel">
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate  TargetType="telerik:GridViewGroupPanel">
                <Grid Background="Transparent">
                    <Border HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Opacity="0.6" />
                    <Border HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
                    <WrapPanel Margin="-2,0,0,0">
                        <ItemsPresenter x:Name="itemsPresenter" Margin="0,20,3,0" />
                    </WrapPanel>
                    <StackPanel Orientation="Vertical" Margin="10,10,0,0" >
                        <TextBlock x:Name="Text1" Text="Logged Events" FontFamily="Times New Roman" FontSize="20" IsHitTestVisible="False" VerticalAlignment="Center"  />
                        <TextBlock x:Name="Text2" Text="Drag a column header and drop it here to group by that column" Opacity="0.5" FontFamily="Arial" FontSize="10" IsHitTestVisible="False" VerticalAlignment="Center"  />
                    </StackPanel>
                </Grid>
                <ControlTemplate.Triggers>
                    <!--Grouping HasGroups State-->
                    <Trigger Property="HasItems" Value="True">
                        <Setter Property="Visibility" TargetName="Text1" Value="Collapsed"/>
                        <Setter Property="Visibility" TargetName="Text2" Value="Collapsed"/>
                    </Trigger>
                </ControlTemplate.Triggers>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>


Kind regards,
Pavel Pavlov
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
GridView
Asked by
Marco
Top achievements
Rank 1
Answers by
Pavel Pavlov
Telerik team
Jérôme Gaborieau
Top achievements
Rank 1
Byron
Top achievements
Rank 1
jas
Top achievements
Rank 1
Share this question
or