Skip to main content
All docs
V25.1
  • TreeListDocumentExportOptions.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<TreeListDocumentExportCustomizeColumnEventArgs> CustomizeColumn { get; set; }

    Property Value

    Type Description
    Action<TreeListDocumentExportCustomizeColumnEventArgs>

    A delegate method that customizes table columns.

    Remarks

    When exporting TreeList 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 exported column width.
    Style Columns
    Specify the DataCellStyle event argument to style all data cells that belong to the processed column.

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

    @rendermode InteractiveServer
    @using DevExpress.Drawing
    @inject SpaceObjectDataProvider SpaceObjectDataProvider
    
    <DxTreeList @ref="TreeList" Data="TreeListData" ChildrenFieldName="Satellites">
        <Columns>
            <DxTreeListDataColumn FieldName="Name" />
            <DxTreeListDataColumn FieldName="TypeOfObject" Caption="Type" />
            <DxTreeListDataColumn FieldName="Mass10pow21kg" Caption="Mass, kg" DisplayFormat="N2" />
            <DxTreeListDataColumn FieldName="MeanRadiusInKM" Caption="Radius, km" DisplayFormat="N2" />
            <DxTreeListDataColumn FieldName="Volume10pow9KM3" Caption="Volume, km³" DisplayFormat="N2" Visible="false" />
            <DxTreeListDataColumn FieldName="SurfaceGravity" Caption="Gravity" DisplayFormat="N2" Visible="false" />
        </Columns>
        <ToolbarTemplate>
            <DxToolbar>
                <DxToolbarItem Text="Export to PDF" Click="ExportPdf_Click" BeginGroup="true" />
            </DxToolbar>
        </ToolbarTemplate>
    </DxTreeList>
    
    @code {
        ITreeList TreeList { get; set; }
        object TreeListData { get; set; }
        protected override async Task OnInitializedAsync() {
            TreeListData = SpaceObjectDataProvider.GenerateData();
        }
        async Task ExportPdf_Click() {
            await TreeList.ExportToPdfAsync("ExportResult", new TreeListPdfExportOptions() {
                FitToPage = false,
                CustomizeColumn = OnCustomizeColumn,
            });
        }
        void OnCustomizeColumn (TreeListDocumentExportCustomizeColumnEventArgs args) {
            args.Width = 300;
            args.IsHidden = false;
            if (args.ColumnIndex % 2 == 1)
                args.DataCellStyle.BackColor = System.Drawing.Color.LightGray;
            if (args.FieldName == "Name") {
                args.DataCellStyle.Font = new DXFont(args.DataCellStyle.Font, DXFontStyle.Bold);
                args.Width = 400;
            }
        }
    }
    

    Blazor TreeList PDF export - Customize Cells

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

    See Also