blazor-devexpress-dot-blazor-dot-griddocumentexportsummaryitem.md
Returns the summary item’s aggregation function.
Namespace : DevExpress.Blazor
Assembly : DevExpress.Blazor.v25.2.dll
NuGet Package : DevExpress.Blazor
public GridSummaryItemType SummaryType { get; }
| Type | Description |
|---|---|
| GridSummaryItemType |
An aggregation function.
|
Available values:
| Name | Description |
|---|---|
| Sum |
Calculates the sum of all values in a column.
| | Min |
Calculates the minimum value of all values in a column.
| | Max |
Calculates the maximum value of all values in a column.
| | Count |
Calculates the number of values in a column.
| | Avg |
Calculates the average of all values in a column.
| | Custom |
Uses a custom algorithm to calculate a summary value.
| | None |
Does not calculates a summary value.
|
When exporting Grid data to PDF, handle the CustomizeCell event to customize table cells in the output file. Use the SummaryItems property to obtain information about summaries displayed in the processed cell.
The following example customizes the text and formatting of summaries in the exported document:
@rendermode InteractiveServer
@using DevExpress.Drawing;
@inject WeatherForecastService ForecastService
<DxGrid @ref="Grid" Data="@forecasts">
<Columns>
<DxGridDataColumn Caption="Date" FieldName="Date" ExportWidth="500" />
<DxGridDataColumn Caption="Temperature (C)" FieldName="TemperatureC" />
<DxGridDataColumn Caption="Temperature (F)" FieldName="TemperatureF" />
<DxGridDataColumn Caption="Summary" FieldName="Summary" />
</Columns>
<TotalSummary>
<DxGridSummaryItem SummaryType="GridSummaryItemType.Min" FieldName="Date" />
<DxGridSummaryItem SummaryType="GridSummaryItemType.Max" FieldName="Date" />
<DxGridSummaryItem SummaryType="GridSummaryItemType.Min" FieldName="TemperatureC" />
<DxGridSummaryItem SummaryType="GridSummaryItemType.Max" FieldName="TemperatureC" />
</TotalSummary>
<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() {
CustomizeCell = OnCustomizeCell,
});
}
void OnCustomizeCell(GridDocumentExportCustomizeCellEventArgs args) {
if (args.AreaType == DocumentExportAreaType.TotalFooter ) {
if (args.ColumnFieldName == "Date") {
var sum1 = args.SummaryItems[0];
var sum2 = args.SummaryItems[1];
args.Text = sum1.SummaryType + " " + sum1.FieldName + ": " + sum1.Value;
args.Text += "\n" + sum2.SummaryType + " " + sum2.FieldName + ": " + sum2.Value;
}
if (args.ColumnFieldName == "TemperatureC") {
args.Text = args.SummaryItems[0].Text + "°C\n" + args.SummaryItems[1].Text + "°C";
args.ElementStyle.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleRight;
}
}
args.Handled = true;
}
}
using System;
public class WeatherForecast {
public DateTime Date { get; set; }
public int TemperatureC { get; set; }
public string Forecast { get; set; }
public string CloudCover { get; set; }
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
public class WeatherForecastService {
private List<WeatherForecast> Forecast { get; set; }
private static string[] CloudCover = new[] {
"Sunny", "Partly cloudy", "Cloudy", "Storm"
};
Tuple<int, string>[] ConditionsForForecast = new Tuple<int, string>[] {
Tuple.Create( 22 , "Hot"),
Tuple.Create( 13 , "Warm"),
Tuple.Create( 0 , "Cold"),
Tuple.Create( -10 , "Freezing")
};
public WeatherForecastService() {
Forecast = CreateForecast();
}
private List<WeatherForecast> CreateForecast() {
var rng = new Random();
DateTime startDate = DateTime.Now;
return Enumerable.Range(1, 30).Select(index => {
var temperatureC = rng.Next(-10, 30);
return new WeatherForecast {
Date = startDate.AddDays(index),
TemperatureC = temperatureC,
CloudCover = CloudCover[rng.Next(0, 4)],
Forecast = ConditionsForForecast.First(c => c.Item1 <= temperatureC).Item2
};
}).ToList();
}
public List<WeatherForecast> GetForecast() {
return Forecast;
}
public Task<WeatherForecast[]> GetForecastAsync(CancellationToken ct = default) {
return Task.FromResult(Forecast.ToArray());
}
}
// ...
builder.Services.AddSingleton<WeatherForecastService>();
See Also
GridDocumentExportSummaryItem Class