Skip to main content
All docs
V25.1
  • GridRowExportingEventArgs.Cancel Property

    Specifies whether the row exporting should be canceled.

    Namespace: DevExpress.Blazor

    Assembly: DevExpress.Blazor.v25.1.dll

    NuGet Package: DevExpress.Blazor

    Declaration

    public bool Cancel { get; set; }

    Property Value

    Type Description
    Boolean

    true to cancel the row export; false to export the row.

    Remarks

    The RowExporting action is called before a row is exported and allows you to cancel the action. Write the action handler to filter the exported data. Set the Cancel property to true to prevent the export of the processed row.

    Note

    If you exclude a group row from the exported document, you should also cancel the export of all data rows in that group. Otherwise, the data hierarchy in the resulting document breaks.

    Refer to the RowExporting action description for more information.

    Example

    The following code snippet exports rows that contain values larger than 1000 in the Total column.

    <DxGrid @ref="Grid" Data="@Data" >
        <Columns>
            <DxGridDataColumn FieldName="CompanyName" />
            <DxGridDataColumn FieldName="Country" />
            <DxGridDataColumn FieldName="UnitPrice" DisplayFormat="c" />
            <DxGridDataColumn FieldName="Quantity" />
            <DxGridDataColumn FieldName="Total" UnboundType="GridUnboundColumnType.Integer" 
                              DisplayFormat="c" UnboundExpression="[UnitPrice]*[Quantity]" />
        </Columns>
    </DxGrid>
    <DxButton Text="Export Big Deals to XLSX" Click="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 {
                    OrderDate = i.OrderDate,
                    CompanyName = c.CompanyName,
                    City = i.City,
                    Region = i.Region,
                    Country = i.Country,
                    UnitPrice = i.UnitPrice,
                    Quantity = i.Quantity
                };
            });
        }
        async Task ExportXlsx_Click() {
            var options = new GridXlExportOptions();
            // Exports rows with Total value larger than 1000
            options.RowExporting = e => {
                if (!e.IsGroupRow) {
                    if ((int)e.GetRowValue("Total") < 1000) {
                        e.Cancel = true;
                    }
                }
            };
           await Grid.ExportToXlsxAsync("Big Deals", options);
        }
    }
    

    Grid - Exported big deals

    See Also