TreeListDocumentExportOptions.CustomizeCell Property
Allows you to customize table cells in the exported file.
Namespace: DevExpress.Blazor
Assembly: DevExpress.Blazor.v25.1.dll
NuGet Package: DevExpress.Blazor
Declaration
public Action<TreeListDocumentExportCustomizeCellEventArgs> CustomizeCell { get; set; }
Property Value
Type | Description |
---|---|
Action<TreeListDocumentExportCustomizeCellEventArgs> | A delegate method that customizes table cells. |
Remarks
When exporting TreeList data to PDF, handle the CustomizeCell
event to perform the following actions:
- Substitute the cell text (Text)
- Customize cell appearance (ElementStyle)
Set the Handled property to true
to apply specified settings. Otherwise, the processed cell is exported with default settings.
The AreaType event argument identifies the area containing the processed cell. You can use other event arguments to obtain additional information about the processed cell. Each argument corresponds to an individual area-dependent cell attribute. If the processed cell does not have a specific attribute, the corresponding argument returns null
. The following table lists cell attributes available for different area types:
Header | Data Area | Total Footer | |
---|---|---|---|
ColumnFieldName | ![]() |
![]() |
![]() |
DataItem | ![]() |
![]() |
![]() |
SummaryItems | ![]() |
![]() |
![]() |
Value | ![]() |
![]() |
![]() |
The following example exports TreeList data to PDF and customizes the output table appearance:
@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>
<TotalSummary>
<DxTreeListSummaryItem SummaryType="TreeListSummaryItemType.Count" FieldName="Name" />
<DxTreeListSummaryItem SummaryType="TreeListSummaryItemType.Min" FieldName="MeanRadiusInKM" />
<DxTreeListSummaryItem SummaryType="TreeListSummaryItemType.Max" FieldName="MeanRadiusInKM" />
</TotalSummary>
<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() {
CustomizeCell = OnCustomizeCell,
});
}
void OnCustomizeCell(TreeListDocumentExportCustomizeCellEventArgs args) {
if (args.AreaType == DocumentExportAreaType.Header) {
args.ElementStyle.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter;
args.ElementStyle.Font = new DXFont("Arial", 10, DXFontStyle.Bold);
}
if (args.AreaType == DocumentExportAreaType.DataArea) {
var spaceObject = (SpaceObject)args.DataItem;
if (spaceObject.TypeOfObject == "Planet")
args.ElementStyle.BackColor = System.Drawing.Color.LightBlue;
if (args.ColumnFieldName == "Mass10pow21kg" && (double)args.Value > 10)
args.ElementStyle.Font = new DXFont(args.ElementStyle.Font, DXFontStyle.Bold);
}
if (args.AreaType == DocumentExportAreaType.TotalFooter && args.ColumnFieldName == "MeanRadiusInKM") {
args.Text = args.SummaryItems[0].Text + " km\n" + args.SummaryItems[1].Text + "km";
args.ElementStyle.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleRight;
}
args.Handled = true;
}
}
Refer to the following topic for additional information: Export Blazor TreeList Data to PDF.