Skip to main content

GridExportCustomizeCellEventArgs.GroupFieldName Property

Returns the name of a data source field bound to the processed group header or footer.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v24.1.dll

NuGet Package: DevExpress.Blazor

Declaration

public string GroupFieldName { get; }

Property Value

Type Description
String

The field name or null if the processed cell does not belong to a group header or footer.

Remarks

The CustomizeCell action allows you to customize a cell in the exported file. You can use the AreaType property to determine where the processed cell is placed.

When a group row or group footer cell is being processed (the AreaType property returns the GroupHeader or GroupFooter value), use the GroupFieldName property to get the name of a data source field that is used to group grid data.

If the processed cell belongs to another area type, the GroupFieldName property returns null.

<DxGrid @ref="Grid" Data="@Data" >
    <Columns>
        <DxGridDataColumn FieldName="ContactName" />
        <DxGridDataColumn FieldName="CompanyName" />
        <DxGridDataColumn FieldName="Country" GroupIndex="0" />
        <DxGridDataColumn FieldName="City" GroupIndex="1" />
    </Columns>
</DxGrid>
<DxButton Text="Export to XLSX" Click="ExportXlsx_Click" />
@code {
    IGrid Grid { get; set; }
    / ...
    async Task ExportXlsx_Click() {
        var options = new GridXlExportOptions();
        options.CustomizeCell = (e) => {
            if (e.AreaType == DevExpress.Export.SheetAreaType.GroupHeader) {
                if (e.GroupFieldName == "Country"){
                    e.Formatting.BackColor = System.Drawing.Color.Bisque;
                } else if (e.GroupFieldName == "City"){
                    e.Formatting.BackColor = System.Drawing.Color.Cornsilk;
                };
                e.Handled = true;
            }
        };
        await Grid.ExportToXlsxAsync("ExportResult", options);
    }
}

Grid - Colored Group Rows

See Also