aspnet-devexpress-dot-web-dot-aspxgridview-4342ec85.md
Fires when a total summary item is added to the ASPxGridView.TotalSummary collection using the context menu.
Namespace : DevExpress.Web
Assembly : DevExpress.Web.v25.2.dll
NuGet Package : DevExpress.Web
public event ASPxGridViewAddSummaryItemViaContextMenuEventHandler AddSummaryItemViaContextMenu
Public Event AddSummaryItemViaContextMenu As ASPxGridViewAddSummaryItemViaContextMenuEventHandler
The AddSummaryItemViaContextMenu event's data class is ASPxGridViewAddSummaryItemViaContextMenuEventArgs. The following properties provide information specific to this event:
| Property | Description |
|---|---|
| Column | Gets a data column to whose footer a summary item is added. |
| IsGroupSummary | Indicates whether a total summary item or a group summary item has been added to a summary collection using the context menu. |
| SummaryItem | Gets a summary item that is added to the grid footer. |
The AddSummaryItemViaContextMenu event fires when a total summary item is added to the ASPxGridView.TotalSummary collection using the context menu. You can use this event handler to provide a custom display format for a summary item.
Note
The context menu allows end-users to add and remove total summary items from the ASPxGridView.TotalSummary collection. However, if a total summary item is added to the ASPxGridView.TotalSummary collection programmatically (in markup or in code behind), the context menu allows end-users to hide this item (set the ASPxSummaryItemBase.Visible property to false) retaining it in the collection.
The code sample below demonstrates how to handle the AddSummaryItemViaContextMenu event to format a summary item’s display text. The complete sample is available in the DevExpress online demo Grid Columns - Context Menu.
protected void Grid_AddSummaryItemViaContextMenu(object sender, ASPxGridViewAddSummaryItemViaContextMenuEventArgs e) {
if(e.SummaryItem.FieldName == "UnitsInStock" && e.SummaryItem.SummaryType == SummaryItemType.Average)
e.SummaryItem.ValueDisplayFormat = "{0:0.00}";
}
Protected Sub Grid_AddSummaryItemViaContextMenu(ByVal sender As Object, ByVal e As ASPxGridViewAddSummaryItemViaContextMenuEventArgs)
If e.SummaryItem.FieldName = "UnitsInStock" AndAlso e.SummaryItem.SummaryType = SummaryItemType.Average Then
e.SummaryItem.ValueDisplayFormat = "{0:0.00}"
End If
End Sub
<dx:ASPxGridView runat="server" ID="Grid" ClientInstanceName="Grid" DataSourceID="DemoDataSource1" OnAddSummaryItemViaContextMenu="Grid_AddSummaryItemViaContextMenu" ... >
<Columns>
<dx:GridViewDataSpinEditColumn FieldName="UnitsInStock">
<PropertiesSpinEdit MinValue="0" MaxValue="10000" />
</dx:GridViewDataSpinEditColumn>
...
</Columns>
</dx:ASPxGridView>
See Also