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

ASPxGridBase.CustomSummaryCalculate Event

Enables you to calculate summary values manually.

Namespace: DevExpress.Web

Assembly: DevExpress.Web.v19.2.dll

Declaration

public event CustomSummaryEventHandler CustomSummaryCalculate

Event Data

The CustomSummaryCalculate event's data class is CustomSummaryEventArgs. The following properties provide information specific to this event:

Property Description
FieldValue Gets the processed field value.
GroupLevel Gets the nested level of the group whose summary value is being calculated.
GroupRowHandle Gets a value identifying the group row whose child data rows are involved in summary calculation.
IsGroupSummary Gets whether a group summary value is being calculated.
IsTotalSummary Gets whether a total summary value is being calculated.
Item Gets a summary item whose value is being calculated.
Row Gets the currently processed row.
RowHandle Gets the handle of the processed row.
SummaryProcess Gets a value indicating calculation stage.
TotalValue Gets or sets the total summary value.
TotalValueReady Gets or sets whether the Calculation stage of the custom summary calculation process should be skipped.

The event data class exposes the following methods:

Method Description
GetGroupSummary(Int32, Object) Returns the value of the specified group summary for the specified group row.
GetValue(String) Returns the value in the specified field

Remarks

Total summaries and group summaries provide five predefined aggregate functions. These functions allow you to calculate the number of rows, the maximum and minimum values, the sum and the average value. If you need to calculate a summary value using an aggregate function not included in the predefined set, set the summary item’s ASPxSummaryItemBase.SummaryType property to Custom and handle the CustomSummaryCalculate event.

The CustomSummaryCalculate event fires for each row involved in summary calculation. When calculating a total summary value, the event is raised for each data row (column or record). When calculating a group summary value for the ASPxGridView, the event fires for each data row within the currently processed group.

Additionally, the event is raised before and after processing rows. This can be used to perform any initialization and finalization.

Note

  • The custom summary calculation option is not available in server mode. Please refer to the Data Binding to Large Data via XPO help topic for more information.
  • The CustomSummaryCalculate event is not raised on callbacks if the grid’s data is not updated.

Find control-specific information (for ASPxGridView, ASPxCardView or ASPxVerticalGrid) in the sections below.

You can use the GetValue method to get the required value in the CustomSummaryCalculate event handler.

ASPxGridView

Example

<dx:ASPxGridView ID="ASPxGridView1" runat="server" OnCustomCallback="ASPxGridView1_CustomCallback" AutoGenerateColumns="False" 
DataSourceID="SqlDataSource1" ClientInstanceName="grid" Theme="Office365" KeyFieldName="ProductID" 
OnCustomSummaryCalculate="ASPxGridView1_CustomSummaryCalculate">
    <Columns>
        <dx:GridViewCommandColumn SelectAllCheckboxMode="Page" ShowSelectCheckbox="True" VisibleIndex="0">
        </dx:GridViewCommandColumn>
        <dx:GridViewDataTextColumn FieldName="ProductID" VisibleIndex="1" ReadOnly="True">
            <EditFormSettings Visible="False" />
        </dx:GridViewDataTextColumn>
        <dx:GridViewDataTextColumn FieldName="ProductName" VisibleIndex="2">
        </dx:GridViewDataTextColumn>
        <dx:GridViewDataTextColumn FieldName="UnitPrice" VisibleIndex="3">
        </dx:GridViewDataTextColumn>
    </Columns>
    <Settings ShowFooter="true" />
    <TotalSummary>
        <dx:ASPxSummaryItem SummaryType="Custom" FieldName="UnitPrice" ShowInColumn="UnitPrice" 
        DisplayFormat="Total price for selected products: {0:c}" ValueDisplayFormat="{0}:c" />
    </TotalSummary>
</dx:ASPxGridView>
<br /> <br />
<dx:ASPxButton ID="ASPxButton4" runat="server" Text="Calculate summary" AutoPostBack="false" Theme="Office365">
    <ClientSideEvents Click="OnClick" />
</dx:ASPxButton>

Result:

Online Demo

ASPxGridView - Export Selected Records

ASPxCardView

Example

<dx:ASPxCardView ID="ASPxCardView1" runat="server" DataSourceID="SqlDataSource1" Width="40%" Theme="Office365" 
OnCustomSummaryCalculate="ASPxCardView1_CustomSummaryCalculate" OnCustomCallback="ASPxCardView1_CustomCallback" 
ClientInstanceName="cardView" AutoGenerateColumns="False" KeyFieldName="ProductID">
    <SettingsPager>
        <SettingsTableLayout ColumnCount="2" RowsPerPage="2" />
    </SettingsPager>
    <Settings LayoutMode="Table" ShowSummaryPanel="true" />
    <SettingsExport ExportSelectedCardsOnly="False"></SettingsExport>
    <Columns>
    ...
    </Columns>
    <CardLayoutProperties>
        <Items>
            <dx:CardViewCommandLayoutItem ColSpan="1" HorizontalAlign="Right" ShowSelectCheckbox="True">
            </dx:CardViewCommandLayoutItem>
            <dx:CardViewColumnLayoutItem ColumnName="ProductName" />
        </Items>
    </CardLayoutProperties>
    <StylesExport>
    ...
    </StylesExport>
    <TotalSummary>
        <dx:ASPxCardViewSummaryItem SummaryType="Custom" FieldName="UnitPrice" 
        DisplayFormat="Total price for selected products: {0:c}" ValueDisplayFormat="{0}:c" />
    </TotalSummary>
</dx:ASPxCardView>
<br /> <br />
<dx:ASPxButton ID="ASPxButton4" runat="server" Text="Calculate summary" AutoPostBack="false" Theme="Office365" >
    <ClientSideEvents Click="OnClick" />                
</dx:ASPxButton>

Result:

Online Demo

ASPxCardView - Export Selected Cards

ASPxVerticalGrid

Example

<dx:ASPxVerticalGrid ID="ASPxVerticalGrid1" runat="server" ClientInstanceName="vgrid"
OnCustomSummaryCalculate="ASPxVerticalGrid1_CustomSummaryCalculate" OnCustomCallback="ASPxVerticalGrid1_CustomCallback" 
Width="700px" AutoGenerateRows="False" DataSourceID="SqlDataSource1" KeyFieldName="ProductID" Theme="Office365">
    <Rows>
    ...
    </Rows>
    <TotalSummary>
        <dx:ASPxVerticalGridSummaryItem SummaryType="Custom" FieldName="UnitPrice" 
        DisplayFormat="Total price for selected products: {0:c}" ValueDisplayFormat="{0}:c" />
    </TotalSummary>
    <Settings ShowSummaryPanel="true" />
</dx:ASPxVerticalGrid>

<dx:ASPxButton ID="ASPxButton4" runat="server" Text="Calculate summary" AutoPostBack="false" 
Theme="Office365" >
    <ClientSideEvents Click="OnClick" />                
</dx:ASPxButton>

See Also