
Michelle Tan
Top achievements
Rank 1
Michelle Tan
asked on 02 Nov 2012, 01:36 AM
Hi guys, How do I remove the group header text. It show example Title : Book A. I only want to display Book A as the text only. Please help.Thanks
<
GroupByExpressions
>
<
telerik:GridGroupByExpression
>
<
SelectFields
>
<
telerik:GridGroupByField
FieldName
=
"Title"
FormatString
=
""
HeaderText
=
""
/>
</
SelectFields
>
<
GroupByFields
>
<
telerik:GridGroupByField
FieldName
=
"Title"
SortOrder
=
"Ascending"
>
</
telerik:GridGroupByField
>
</
GroupByFields
>
</
telerik:GridGroupByExpression
>
</
GroupByExpressions
>
9 Answers, 1 is accepted
0
Accepted

Shinu
Top achievements
Rank 2
answered on 02 Nov 2012, 03:34 AM
Hi,
Please try the following code snippet to change the GroupHeaderText.
C#:
Check this documentation for more reference.
Thanks,
Shinu.
Please try the following code snippet to change the GroupHeaderText.
C#:
protected
void
rdgSurveys_ItemDataBound(
object
sender, Telerik.Web.UI.GridItemEventArgs e)
{
if
(e.Item
is
GridGroupHeaderItem)
{
GridGroupHeaderItem item = (GridGroupHeaderItem)e.Item;
DataRowView groupDataRow = (DataRowView)e.Item.DataItem;
item.DataCell.Text = groupDataRow[
"Tittle"
].ToString();
}
}
Check this documentation for more reference.
Thanks,
Shinu.
0

Michelle Tan
Top achievements
Rank 1
answered on 02 Nov 2012, 06:08 AM
Thanks. It work perfectly :)
0

Rayne
Top achievements
Rank 1
answered on 24 Jul 2013, 05:15 PM
I have a question about this.
I'm trying to customize the group header text, but only for a certain column. Using the code mentioned above doesn't complete my issue, because it will try to change the group header text that no matter what column is being grouped and this causes an error if the specified column isn't being grouped. How do I check which column is being grouped?
I'm trying to customize the group header text, but only for a certain column. Using the code mentioned above doesn't complete my issue, because it will try to change the group header text that no matter what column is being grouped and this causes an error if the specified column isn't being grouped. How do I check which column is being grouped?
0
Hello Rayne,
You can access the groupheader row and thereby change the text to some custom text. This is explained in detail in the following help document:
Customizing GridGroupHeaderItem
Regards,
Maria Ilieva
Telerik
You can access the groupheader row and thereby change the text to some custom text. This is explained in detail in the following help document:
Customizing GridGroupHeaderItem
Regards,
Maria Ilieva
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
0

Rayne
Top achievements
Rank 1
answered on 29 Jul 2013, 01:03 PM
I've tried using the documentation mentioned, but I'm still having trouble. I need to figure out which column is being grouped, because that will determine what gets put in the header text.
Let's say I have three columns - ColA, ColB and ColC. For ColA, I want the group header to say "Column A", for ColB, when grouped it needs to say "Group B" and for ColC it needs to say "Category C". So each group header is different. Some of them get additional data from a database...they are key values and I want to include the description of the value (which resides in a different database, so I get it at the time of the grouping).
How do I know which column is being grouped so I can set the header text accordingly? I couldn't figure out how to tell which column is being grouped, except to use groupDataRow["column_name"], but if it doesn't exist, then it throws an error. There has to be a better way than catching an exception, right?
Let's say I have three columns - ColA, ColB and ColC. For ColA, I want the group header to say "Column A", for ColB, when grouped it needs to say "Group B" and for ColC it needs to say "Category C". So each group header is different. Some of them get additional data from a database...they are key values and I want to include the description of the value (which resides in a different database, so I get it at the time of the grouping).
How do I know which column is being grouped so I can set the header text accordingly? I couldn't figure out how to tell which column is being grouped, except to use groupDataRow["column_name"], but if it doesn't exist, then it throws an error. There has to be a better way than catching an exception, right?
0
Hello Rayne,
Try using to approach below for determine which column was grouped:
Regards,
Maria Ilieva
Telerik
Try using to approach below for determine which column was grouped:
protected
void
Button2_Click(
object
sender, EventArgs e)
{
if
(RadGrid1.MasterTableView.GroupByExpressions.Count > 0)
{
GridGroupByExpression exp = (GridGroupByExpression)RadGrid1.MasterTableView.GroupByExpressions[0];
string
groupedField = exp.GroupByFields[0].FieldName.ToString();
// Response.Write(groupedField);
}
}
Regards,
Maria Ilieva
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
0

Rayne
Top achievements
Rank 1
answered on 01 Aug 2013, 03:39 PM
What if the grid is already grouped by ColA for example, then the user decides to group by ColC? How do I make sure that both groupings have the right header content?
0

John
Top achievements
Rank 1
answered on 20 Aug 2013, 08:53 PM
Related point, can we localize the HeaderText property using a resource file? Or does it have to be done in code using much the same way technique in the ItemDataBound event?
0
Hello John,
When using resource file you could add the following to set the column HeaderText property:
And in the resource file you will have:
More information about using resource files can be found at our help article: "Localization through resource files".
Hope that helps.
Regards,
Konstantin Dikov
Telerik
When using resource file you could add the following to set the column HeaderText property:
<
Columns
>
<
telerik:GridBoundColumn
DataField
=
"CustomerID"
HeaderText='<%$ Resources:Resource, Header1 %>'></
telerik:GridBoundColumn
>
</
Columns
>
And in the resource file you will have:
......
<
data
name
=
"Header1"
xml:space
=
"preserve"
>
<
value
>Some header text</
value
>
</
data
>
</
root
>
More information about using resource files can be found at our help article: "Localization through resource files".
Hope that helps.
Regards,
Konstantin Dikov
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.