Skip to main content
All docs
V25.1
  • GridDocumentExportOptions.CustomizeColumn Property

    Allows you to customize table columns in the exported document.

    Namespace: DevExpress.Blazor

    Assembly: DevExpress.Blazor.v25.1.dll

    NuGet Package: DevExpress.Blazor

    Declaration

    public Action<GridDocumentExportCustomizeColumnEventArgs> CustomizeColumn { get; set; }

    Property Value

    Type Description
    Action<GridDocumentExportCustomizeColumnEventArgs>

    A delegate method that customizes table columns.

    Property Paths

    You can access this nested property as listed below:

    Object Type Path to CustomizeColumn
    GridExportEventArgs
    .DocumentOptions .CustomizeColumn

    Remarks

    When exporting Grid data to PDF, handle the CustomizeColumn event to perform the following actions:

    Identify Columns
    Use FieldName and ColumnIndex event arguments to determine the processed column and its position in the output table.
    Display/Hide Columns
    Use the IsHidden event argument to display/hide the processed column.
    Resize Columns
    Specify the Width event argument to modify the column width.
    Style Columns
    Specify the DataCellStyle event argument to style all data cells that belong to the processed column.

    The following example exports Grid data to PDF and customizes output table appearance:

    @rendermode InteractiveServer
    @using DevExpress.Drawing;
    @inject WeatherForecastService ForecastService
    
    <DxGrid @ref="Grid" Data="@forecasts">
        <Columns>
            <DxGridDataColumn Caption="Date" FieldName="Date" />
            <DxGridDataColumn Caption="Summary" FieldName="Summary" />
            <DxGridDataColumn Caption="Temperature (C)" FieldName="TemperatureC" />
            <DxGridDataColumn Caption="Temperature (F)" FieldName="TemperatureF" Visible="false" />
        </Columns>
        <ToolbarTemplate>
            <DxToolbar>
                <DxToolbarItem Text="Export to PDF" Click="ExportPdf_Click" BeginGroup="true" />
            </DxToolbar>
        </ToolbarTemplate>
    </DxGrid>
    
    @code {
        IGrid Grid;
        private WeatherForecast[]? forecasts;
    
        protected override async Task OnInitializedAsync() {
            forecasts = await ForecastService.GetForecastAsync(DateOnly.FromDateTime(DateTime.Now));
        }
        async Task ExportPdf_Click() {
            await Grid.ExportToPdfAsync("ExportResult", new GridPdfExportOptions() {
                FitToPage = false,
                CustomizeColumn = OnCustomizeColumn,
            });
        }
        void OnCustomizeColumn(GridDocumentExportCustomizeColumnEventArgs args) {
            args.Width = 400;
            args.IsHidden = false;
            if (args.ColumnIndex % 2 == 1)
                args.DataCellStyle.BackColor = System.Drawing.Color.LightGray;
            if (args.FieldName == "Date")
                args.DataCellStyle.Font = new DXFont(args.DataCellStyle.Font, DXFontStyle.Bold);
        }
    }
    

    Blazor Grid PDF export - Customize Columns

    Refer to the following topic for additional information: Export Blazor Grid Data to PDF.

    See Also