Skip to main content
All docs
V25.2
  • TreeListExportOptions.ExportSelectedRowsOnly Property

    Specifies whether the TreeList exports selected rows only.

    Namespace: DevExpress.Blazor

    Assembly: DevExpress.Blazor.v25.2.dll

    NuGet Package: DevExpress.Blazor

    Declaration

    [DefaultValue(false)]
    public override bool ExportSelectedRowsOnly { get; set; }

    Property Value

    Type Default Description
    Boolean false

    true to export the selected rows only; false to export all TreeList rows.

    Remarks

    When ExportSelectedRowsOnly is enabled, the TreeList component ignores hierarchy and exports selected records as flat data. Set SelectedRowsExportMode to KeepHierarchy to export selected rows and their parents.

    The following example exports selected rows and their parents to XLSX:

    @rendermode InteractiveServer
    @inject SpaceObjectDataProvider SpaceObjectDataProvider
    
    <DxTreeList @ref="TreeList" Data="TreeListData" ChildrenFieldName="Satellites">
        <Columns>
            <DxTreeListSelectionColumn Width="60px" AllowSelectAll="true" />
            <DxTreeListDataColumn FieldName="Name" />
            <DxTreeListDataColumn FieldName="TypeOfObject" Caption="Type" />
            <DxTreeListDataColumn FieldName="Mass10pow21kg" Caption="Mass, kg" DisplayFormat="N2" />
            <DxTreeListDataColumn FieldName="MeanRadiusInKM" Caption="Radius, km" DisplayFormat="N2"/>
        </Columns>
        <ToolbarTemplate>
            <DxToolbar>
                <DxToolbarItem Text="Export to XLSX" Click="ExportXlsx_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 ExportXlsx_Click() {
            await TreeList.ExportToXlsxAsync("ExportResult", new TreeListXlExportOptions() {
                ExportSelectedRowsOnly = true,
                SelectedRowsExportMode = TreeListSelectedRowsExportMode.KeepHierarchy
            });
        }
    }
    

    Excel Export - Flat Selected Rows Export Mode

    Read Tutorial: Export to XLS/XLSX Run Demo: Export Data

    See Also