GridDocumentExportOptions.RowExporting Property
Fires before a row is exported and allows you to cancel the action.
Namespace: DevExpress.Blazor
Assembly: DevExpress.Blazor.v25.1.dll
NuGet Package: DevExpress.Blazor
Declaration
public Action<GridRowExportingEventArgs> RowExporting { get; set; }
Property Value
Type | Description |
---|---|
Action<GridRowExportingEventArgs> | A delegate method that specifies whether the row export should be canceled. |
Property Paths
You can access this nested property as listed below:
Object Type | Path to RowExporting |
---|---|
GridExportEventArgs |
|
Remarks
The Grid exports all data rows that match the current filter criteria (including rows in collapsed groups). Handle the RowExporting
event to filter exported data.
The Grid raises this event both for data and group rows. Use the IsGroupRow event argument to determine the processed row type. The following arguments allow you to obtain additional information about the processed row:
- DataItem
- Returns the data source item bound to the processed row or
null
(if a group row is processed). - GroupFieldName
- Returns the column field name of the processed group or
null
(if a data row is processed). - GetRowValue
- Returns the specified field’s value in the current row. If a group row is processed, pass the GroupFieldName to the
GetRowValue
method to obtain the group value.
Assign true
to the Cancel event argument to exclude the processed row from the exported document.
Note
If you exclude a group row from the exported document, you should also exclude all data rows that belong to this group. Otherwise, the data hierarchy in the resulting document breaks.
Refer to the following topic for additional information: Export Blazor Grid Data to PDF.
Example
The following example cancels export to PDF for Sweltering group rows and rows whose Temperature C is less than 0
:
@rendermode InteractiveServer
@using DevExpress.Drawing;
@inject WeatherForecastService ForecastService
<DxGrid @ref="Grid" Data="@forecasts">
<Columns>
<DxGridDataColumn Caption="Date" FieldName="Date" />
<DxGridDataColumn Caption="Temperature (C)" FieldName="TemperatureC" />
<DxGridDataColumn Caption="Temperature (F)" FieldName="TemperatureF" />
<DxGridDataColumn Caption="Summary" FieldName="Summary" />
</Columns>
<ToolbarTemplate>
<DxToolbar>
<DxToolbarItem Text="Export to PDF" Click="ExportPdf_Click" BeginGroup="true" />
</DxToolbar>
</ToolbarTemplate>
</DxGrid>
@code {
IGrid Grid;
private WeatherForecast[]? forecasts;
protected override async Task OnInitializedAsync() {
forecasts = await ForecastService.GetForecastAsync(DateOnly.FromDateTime(DateTime.Now));
}
async Task ExportPdf_Click() {
await Grid.ExportToPdfAsync("ExportResult", new GridPdfExportOptions() {
RowExporting = OnRowExporting,
});
}
void OnRowExporting(GridRowExportingEventArgs args) {
if (args.IsGroupRow) {
if (args.GetRowValue(args.GroupFieldName).ToString() == "Sweltering")
args.Cancel = true;
} else {
var forecast = (WeatherForecast) args.DataItem;
if (forecast.Summary == "Sweltering" || forecast.TemperatureC < 0)
args.Cancel = true;
}
}
}