Back to Devexpress

GridViewSettings.CustomSummaryCalculate Property

aspnet-devexpress-dot-web-dot-mvc-dot-gridviewsettings-09929852.md

latest2.5 KB
Original Source

GridViewSettings.CustomSummaryCalculate Property

Enables you to calculate summary values manually.

Namespace : DevExpress.Web.Mvc

Assembly : DevExpress.Web.Mvc5.v20.1.dll

NuGet Package : DevExpress.Web.Mvc5

Declaration

csharp
public CustomSummaryEventHandler CustomSummaryCalculate { get; set; }
vb
Public Property CustomSummaryCalculate As CustomSummaryEventHandler

Property Value

TypeDescription
CustomSummaryEventHandler

A CustomSummaryEventHandler delegate method allowing you to implement custom processing.

|

Remarks

Note

The custom summary calculation option is not available in server mode. Please refer to the Binding to Large Data (Database Server Mode) help topic for more information.

Example

razor
settings.CustomSummaryCalculate = (s, e) => {
    ASPxSummaryItem summary = e.Item as ASPxSummaryItem;
    MVCxGridView gridView = s as MVCxGridView;
    if (summary.FieldName != "TotalAmount")
        return;
    if (e.IsGroupSummary) {
        decimal totalValue;
        if (e.SummaryProcess == Start) {
            totalValue = 0;
        } else if (e.SummaryProcess == Calculate) {
            bool isCancelled = (bool)e.GetValue("isCancelled");
            if (!isCancelled) {
                totalValue += (int)e.FieldValue;
            }
        }
        else if (e.SummaryProcess == Finalize) {
            e.TotalValue = totalValue;
            e.TotalValueReady = true;
        }
    }
}

See Also

Declaring Server-Side Event Handlers

Grid View

GridViewSettings Class

GridViewSettings Members

DevExpress.Web.Mvc Namespace