Skip to main content

DxGridDataColumn.ExportEnabled Property

Specifies whether the grid can export the current column.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v24.1.dll

NuGet Package: DevExpress.Blazor

Declaration

[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.

<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