Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

GridExportOptions.ExportSelectedRowsOnly Property

Specifies if the grid exports only selected rows.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v24.2.dll

NuGet Package: DevExpress.Blazor

#Declaration

C#
[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 grid rows.

#Remarks

Set the ExportSelectedRowsOnly property to true to export selected rows only. If you want to do so when the Grid component is bound to a GridDevExtremeDataSource object, specify the KeyFieldName property.

The following code snippet activates this option:

Razor
<DxGrid @ref="@Grid" Data="Orders" AllowSelectRowByClick="true" >
    <Columns>
        <DxGridSelectionColumn />
        <DxGridDataColumn FieldName="ShipName" />
        <DxGridDataColumn FieldName="ShipCity" />
        <DxGridDataColumn Caption="Date" FieldName="RequiredDate" />
    </Columns>
</DxGrid>
<DxButton Text="Export to XLSX" Click="ExportXlsx_Click" />
@code {
    IGrid Grid { get; set; }
    IEnumerable<Order> Orders { get; set; }
    protected override async Task OnInitializedAsync() {
        Orders = await NwindDataService.GetOrdersAsync();
    }
    async Task ExportXlsx_Click() {
        var options = new GridXlExportOptions();
        options.ExportSelectedRowsOnly = true;
       await Grid.ExportToXlsxAsync("ExportResult", options);
    }
}

Run Demo: Grid - Export Data

For more information about data export in the Grid component, refer to the following topic: Export Data in Blazor Grid.

See Also