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

GridViewColumnGroup

6 Answers 196 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Matthias Bibo
Top achievements
Rank 1
Matthias Bibo asked on 11 Jan 2012, 11:13 AM

Hi,

I was wondering if it is somehow possible to change the GridViewColumnGroup Header property at runtime in code behind.
I tried accessing the GridViewColumnGroups via x:Name in codebehind, but they are always null.

Binding the Header didn't work either.
Is there a way to change the header Content at runtime, for example writing the current month to the header?

Thanks & Best Regards,
Matthias

6 Answers, 1 is accepted

Sort by
0
Accepted
Nick
Telerik team
answered on 11 Jan 2012, 02:16 PM
Hello,

There are a couple of ways that this can be implemented. 
You can define your own HeaderTemplate for the ColumnGroup where you can use a TextBlock and Bind the text that you want to change. 

<telerik:GridViewColumnGroup  Name="Vehicle" >
                    <telerik:GridViewColumnGroup.HeaderTemplate>
                        <DataTemplate>
                            <TextBlock Text="{Binding HEADER_TEXT}"/>
                        </DataTemplate>
                    </telerik:GridViewColumnGroup.HeaderTemplate>
                </telerik:GridViewColumnGroup>

You can also use the ColumnGroups collection of the GridView to manipulate the headers. Note however that for the time being the UI will not be notified about the change in the header, so you will have to apply a simple workaround. 
this.RadGridView.ColumnGroups[DESIRED_HEADER_NAME].Header = HEADER_TEXT ;
 
 
            var columnGroup = new GridViewColumnGroup();
            this.RadGridView.ColumnGroups.Add(columnGroup);
            this.RadGridView.ColumnGroups.Remove(columnGroup);
The notification logic is currently being implemented and will be available in one of our next internal builds.

Hope this helps! 

All the best,
Nik
the Telerik team

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

0
Vinay
Top achievements
Rank 1
answered on 12 Jun 2012, 05:37 AM
Hi,

Can you please explain me how i can bind the values from viewmodel to gridviewcolumngroup headerTemplate Dynamically.
0
Arnaud
Top achievements
Rank 1
answered on 30 Sep 2015, 09:43 AM

Hello,

Facing the same issue​! Please help us, and give us the answer that Vinay is still waiting for... 

Arnaud.

0
Stefan
Telerik team
answered on 05 Oct 2015, 08:32 AM
Hello Arnaud,

Can you please take a look at the GroupHeaderTemplateSelector online demo, as it demonstrates how this can be achieved?

Hope this helps.

Best Regards,
Stefan
Telerik
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 Feedback Portal and vote to affect the priority of the items
0
Arnaud
Top achievements
Rank 1
answered on 06 Oct 2015, 03:42 PM

Hello Stefan,

I'm afraid you did not get the question. I'm speaking about <telerik:GridViewColumnGroup> which are part of <telerik:RadGridView.ColumnGroups>. Nothing to do with groupings of rows.... but with ​merged columns headers!

 Regards,

Arnaud.

 

 

0
Stefan
Telerik team
answered on 09 Oct 2015, 11:12 AM
Hi Arnaud,

Please excuse me for the misunderstanding.

A possible approach for this scenario, is to define the needed DataTemplate and set it at run-time through the HeaderTemplate property of GridViewColumnGroup.
<DataTemplate x:Key="ColumnGroupHeaderTemplate">
    <TextBox Text="Modified"/>
</DataTemplate>
var cg = this.myGrid.ColumnGroups[0];
cg.HeaderTemplate =
    this.Resources["ColumnGroupHeaderTemplate"] as DataTemplate;

Regards,
Stefan X1
Telerik
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 Feedback Portal and vote to affect the priority of the items
Tags
GridView
Asked by
Matthias Bibo
Top achievements
Rank 1
Answers by
Nick
Telerik team
Vinay
Top achievements
Rank 1
Arnaud
Top achievements
Rank 1
Stefan
Telerik team
Share this question
or