TreeListDocumentExportOptions.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<TreeListRowExportingEventArgs> RowExporting { get; set; }
Property Value
Type | Description |
---|---|
Action<TreeListRowExportingEventArgs> | A delegate method that specifies whether the row export should be canceled. |
Remarks
The TreeList exports all data rows that match the current filter criteria (including children of collapsed nodes). Handle the RowExporting
event to filter exported data. The following event arguments allow you to obtain information about the processed row:
- DataItem
- Returns a data source item that is bound to a currently processed row.
- GetRowValue(String)
- Returns the value of the specified data field in the current row.
Assign true
to the Cancel property to exclude the row from the exported document.
Note
If you cancel export for a node that has children, you should also cancel export of all its child nodes. Otherwise, the data hierarchy in the resulting document breaks.
The following example cancels exporting for rows that correspond to space objects other than Star
or Planet
:
@rendermode InteractiveServer
@using DevExpress.Drawing
@inject SpaceObjectDataProvider SpaceObjectDataProvider
<DxTreeList @ref="TreeList" Data="TreeListData" ChildrenFieldName="Satellites">
<Columns>
<DxTreeListDataColumn FieldName="Name" />
<DxTreeListDataColumn FieldName="TypeOfObject" Caption="Type" />
<DxTreeListDataColumn FieldName="Mass10pow21kg" Caption="Mass, kg" DisplayFormat="N2" />
<DxTreeListDataColumn FieldName="MeanRadiusInKM" Caption="Radius, km" DisplayFormat="N2"/>
</Columns>
<ToolbarTemplate>
<DxToolbar>
<DxToolbarItem Text="Export to PDF" Click="ExportPdf_Click" BeginGroup="true" />
</DxToolbar>
</ToolbarTemplate>
</DxTreeList>
@code {
ITreeList TreeList { get; set; }
object TreeListData { get; set; }
protected override async Task OnInitializedAsync() {
TreeListData = SpaceObjectDataProvider.GenerateData();
}
async Task ExportPdf_Click() {
await TreeList.ExportToPdfAsync("ExportResult", new TreeListPdfExportOptions() {
RowExporting = OnRowExporting,
});
}
void OnRowExporting(TreeListRowExportingEventArgs args) {
var spaceObject = (SpaceObject) args.DataItem;
if (spaceObject.TypeOfObject != "Planet" && spaceObject.TypeOfObject != "Star")
args.Cancel = true;
}
}
Refer to the following topic for additional information: Export Blazor TreeList Data to PDF.