New to Telerik UI for WPF? Download free 30-day trial

Format Group Header Cell Content

By handling the ElementExportingToDocument of the RadGridView control, you can specify a custom format for the exported group header cells. For example, you can export the captions of the aggregate results with their formatted value (based on the ResultFormatString of the function) as well as the number of items in the group.

Example 1: Custom Group Header Cell Export Content

private void Grid_ElementExportingToDocument(object sender, GridViewElementExportingToDocumentEventArgs e) 
{ 
    if (e.Element == ExportElement.GroupHeaderCell) 
    { 
        var group = e.DataContext as QueryableCollectionViewGroup; 
        string value = group.Key.ToString() + " (" + group.ItemCount + " items)" + new String(' ', 4); 
        foreach (var result in group.AggregateResults) 
        { 
            value += result.Caption + " " + result.FormattedValue + new String(' ', 4); 
        } 
 
        e.Value = value; 
    } 
} 
Private Sub Grid_ElementExportingToDocument(ByVal sender As Object, ByVal e As GridViewElementExportingToDocumentEventArgs) 
    If e.Element = ExportElement.GroupHeaderCell Then 
        Dim group = TryCast(e.DataContext, QueryableCollectionViewGroup) 
        Dim value As String = group.Key.ToString() & " (" & group.ItemCount & " items)" & New String(" "c, 4) 
        For Each result In group.AggregateResults 
            value &= result.Caption & " " & result.FormattedValue + New String(" "c, 4) 
        Next result 
 
        e.Value = value 
    End If 
End Sub 

Figure 1: Custom Group Header Cell Export Content

Custom Group Header Cell Export Content

See Also

In this article