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

DxGridDataColumn.ExportEnabled Property

Specifies whether the grid can export the current column.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v24.2.dll

NuGet Package: DevExpress.Blazor

#Declaration

C#
[DefaultValue(true)]
[Parameter]
public bool ExportEnabled { get; set; }

#Property Value

Type Default Description
Boolean true

true if the current column can be exported; otherwise, false.

#Remarks

The grid exports data of every data column. A column whose Visible property is set to false is hidden in the document (has a zero width).

Set a column’s ExportEnabled property to false to prevent the export of a specific column’s data.

Razor
<DxGrid @ref="Grid" Data="@Data" UnboundColumnData="Grid_UnboundColumnData">
    <Columns>
        <DxGridDataColumn FieldName="CompanyName" />
        <DxGridDataColumn FieldName="City" />
        <DxGridDataColumn FieldName="Country" ExportEnabled="false" />
        <DxGridDataColumn FieldName="UnitPrice" DisplayFormat="c" ExportEnabled="false" />
        <DxGridDataColumn FieldName="Quantity" ExportEnabled="false" />
        <DxGridDataColumn FieldName="Total" UnboundType="GridUnboundColumnType.Decimal" DisplayFormat="c" />
    </Columns>
</DxGrid>
<OptionButton Text="Export to XLSX" OnClick="ExportXlsx_Click" />
@code {
    object Data { get; set; }
    IGrid Grid { get; set; }
    protected override async Task OnInitializedAsync() {
        var invoices = await NwindDataService.GetInvoicesAsync();
        var customers = await NwindDataService.GetCustomersAsync();
        Data = invoices.OrderBy(i => i.OrderDate).Join(customers, i => i.CustomerId, c => c.CustomerId, (i, c) => {
            return new {
                CompanyName = c.CompanyName,
                City = i.City,
                Region = i.Region,
                Country = i.Country,
                UnitPrice = i.UnitPrice,
                Quantity = i.Quantity
            };
        });
    }
    void Grid_UnboundColumnData(GridUnboundColumnDataEventArgs e) {
        if(e.FieldName == "Total") {
            decimal price = (decimal)e.GetRowValue("UnitPrice");
            short quantity = (short)e.GetRowValue("Quantity");
            e.Value = price * quantity;
        }
    }
    async Task ExportXlsx_Click() {
       await Grid.ExportToXlsxAsync("ExportResult", new GridXlExportOptions());
    }
}

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

#Implements

See Also