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

Change header of GridViewColumnGroup

1 Answer 148 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Pallavi
Top achievements
Rank 1
Pallavi asked on 05 Feb 2014, 12:22 PM
Hi,

I wanted to change header of GridViewColumnGroup in runtime, the values are assigned but not reflected in UI.
How is that possible? how should i change the header of groups?
here is my current code to change it.

  grdTimeRecording.ColumnGroups[1].Header = string.Format("{0:ddd, d MMM}", _firstDate);
            grdTimeRecording.ColumnGroups[2].Header = string.Format("{0:ddd, d MMM}", _firstDate.AddDays(1));
            grdTimeRecording.ColumnGroups[3].Header = string.Format("{0:ddd, d MMM}", _firstDate.AddDays(2));
            grdTimeRecording.ColumnGroups[4].Header = string.Format("{0:ddd, d MMM}", _firstDate.AddDays(3));
            grdTimeRecording.ColumnGroups[5].Header = string.Format("{0:ddd, d MMM}", _firstDate.AddDays(4));
            grdTimeRecording.ColumnGroups[6].Header = string.Format("{0:ddd, d MMM}", _firstDate.AddDays(5));
            grdTimeRecording.ColumnGroups[7].Header = string.Format("{0:ddd, d MMM}", _firstDate.AddDays(6));

1 Answer, 1 is accepted

Sort by
0
Hristo
Telerik team
answered on 07 Feb 2014, 12:18 PM
Hi Pallavi,

There is a simple workaround for this issue. Basically, you would have to add and remove a new columngroup to the gridview, in order to notify the GridView that it's contents have changed. You can use this snippet as an example:
....
this.radGridView.ColumnGroups[2].Header = string.Format("{0:ddd}", new DateTime(1, 1, 1));
 
var columnGroup = new GridViewColumnGroup();
this.radGridView.ColumnGroups.Add(columnGroup);
this.radGridView.ColumnGroups.Remove(columnGroup);
....

Regards,
Hristo
Telerik

Check out the new Telerik Platform - the only modular platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native apps. Register for the free online keynote and webinar to learn more about the Platform on Wednesday, February 12, 2014 at 11:00 a.m. ET (8:00 a.m. PT).

Tags
GridView
Asked by
Pallavi
Top achievements
Rank 1
Answers by
Hristo
Telerik team
Share this question
or