Skip to main content
A newer version of this page is available. .

GridCustomSummaryEventArgs Class

Contains data for the CustomSummary event.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v21.1.dll

NuGet Package: DevExpress.Blazor

Declaration

public class GridCustomSummaryEventArgs

Remarks

Use GridCustomSummaryEventArgs (TotalValue, FieldValue, and so on) to evaluate the summary value and access other grid data.

The example below illustrates how to create a custom summary item, whose value is evaluated and formatted within the CustomSummary and CustomizeSummaryDisplayText event handlers.

<DxGrid Data="GridDataSource"
        UnboundColumnData="Grid_CustomUnboundColumnData"
        CustomizeSummaryDisplayText="Grid_CustomizeSummaryDisplayText"
        CustomSummary="Grid_CustomSummary">
    <Columns>
        <DxGridDataColumn FieldName="ProductId" DisplayFormat="d" />
        <DxGridDataColumn FieldName="UnitPrice" />
        <DxGridDataColumn FieldName="Quantity" />
        <DxGridDataColumn FieldName="Discount" DisplayFormat="p0" />
        <DxGridDataColumn FieldName="TotalPrice"
                      DisplayFormat="c"
                      UnboundType="GridUnboundColumnType.Decimal" />
    </Columns>
    <TotalSummary>
        <DxGridSummaryItem SummaryType="GridSummaryItemType.Sum" FieldName="TotalPrice" />
        <DxGridSummaryItem SummaryType="GridSummaryItemType.Custom" Name="Custom" FieldName="ProductId" />
    </TotalSummary>
</DxGrid>
@* ... *@
@code {
    object GridDataSource { get; set; }
    int totalCount;

    protected override void OnInitialized() {
        GridDataSource = Northwind.OrderDetails
            .Include(i => i.Order)
            .Include(i => i.Product)
            .ToList();
    }

    void Grid_CustomSummary(GridCustomSummaryEventArgs e) {
        if (e.SummaryStage == GridCustomSummaryStage.Start)
            totalCount = 0;
        else if (e.SummaryStage == GridCustomSummaryStage.Calculate) {
            if (Convert.ToInt16(e.GetValue("UnitPrice")) < 20)
                totalCount++;
        }
        else if (e.SummaryStage == GridCustomSummaryStage.Finalize)
            e.TotalValue = totalCount;
    }

    void Grid_CustomizeSummaryDisplayText(GridCustomizeSummaryDisplayTextEventArgs e) {
        if (e.Item.Name == "Custom")
            e.DisplayText = string.Format("Count (Unit Price < 20): {0}", e.Value);
    }
    @* ... *@
}

DevExpress Blazor Grid - Custom Summary

Note

The Grid does not support custom summary calculation when you use a GridDevExtremeDataSource.

Inheritance

Object
GridCustomSummaryEventArgs
See Also