Back to Devexpress

How to: Calculate Custom Total Summaries

aspnet-115351-components-card-view-examples-how-to-calculate-custom-total-summaries.md

latest1.2 KB
Original Source

How to: Calculate Custom Total Summaries

  • Dec 17, 2020

The following example implements a custom summary calculation.

Note that in order to process selection changes on the server side, you can either set the ASPxGridBehaviorSettings.ProcessSelectionChangedOnServer property to true, or handle the ASPxClientCardView.SelectionChanged client event and call the client ASPxClientCardView.PerformCallback method.

csharp
int totalSum;
protected void ASPxCardView1_CustomSummaryCalculate(object sender, CustomSummaryEventArgs e)
{
    if (e.SummaryProcess == DevExpress.Data.CustomSummaryProcess.Start)
        totalSum = 0;
    // Calculation.
    if (e.SummaryProcess == DevExpress.Data.CustomSummaryProcess.Calculate)
        if (ASPxCardView1.Selection.IsCardSelectedByKey(e.GetValue(ASPxCardView1.KeyFieldName)))
            totalSum += Convert.ToInt32(e.FieldValue);
    // Finalization.
    if (e.SummaryProcess == DevExpress.Data.CustomSummaryProcess.Finalize)
        e.TotalValue = totalSum;
}