ASPxGridView.SummaryDisplayText Event
Enables custom display text to be provided for any summary value.
Namespace: DevExpress.Web
Assembly: DevExpress.Web.v19.2.dll
Declaration
public event ASPxGridViewSummaryDisplayTextEventHandler SummaryDisplayText
Public Event SummaryDisplayText As ASPxGridViewSummaryDisplayTextEventHandler
Event Data
Property |
Description |
EncodeHtml |
Gets or sets a value that specifies whether the summary display text keeps any of its values that are HTML as HTML, or instead, strips out the HTML markers.
|
IsGroupSummary |
Indicates whether a group summary value is processed.
|
IsTotalSummary |
Indicates whether a total summary value is being processed.
|
Item |
Gets the processed summary item.
|
Text |
Gets or sets the display text for the summary value currently being processed.
|
Value |
Gets the processed summary value.
|
VisibleIndex |
Gets a value that identifies the group row where the processed summary value is displayed.
|
The SummaryDisplayText event is raised for both group and total summaries. Use the ASPxGridViewSummaryDisplayTextEventArgs.IsGroupSummary and ASPxGridViewSummaryDisplayTextEventArgs.IsTotalSummary properties to identify which summary value is being processed.
Initialy the event parameter’s ASPxGridSummaryDisplayTextEventArgs.Text property contains the text currently displayed in the group row or footer cell. To provide custom text, assign it to this property.
Example
The following example calculates a summary in the CategoryID column based on the value in the ASPxSpinEdit below it.
When an end user changes a spin editor value, the editor sends a custom callback to the server in the client-side NumberChanged event handler. In the server-side SummaryDisplayText event handler, the grid calculates the summary value and sets it to the e.Text parameter.
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class MasterPage : System.Web.UI.MasterPage {
protected void Page_Load(object sender, EventArgs e) {
}
}
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using DevExpress.Web.ASPxEditors;
using DevExpress.Web.ASPxGridView;
using System.Web.UI.WebControls;
public partial class _Default : System.Web.UI.Page {
protected void Page_Load(object sender, EventArgs e) {
}
protected void ASPxGridView1_SummaryDisplayText(object sender, ASPxGridViewSummaryDisplayTextEventArgs e) {
if(e.Item.FieldName == "CategoryID")
e.Text = string.Format("Sum = {0}", Convert.ToDouble(e.Value) * Convert.ToDouble(ASPxSpinEdit1.Value));
}
}
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" MasterPageFile="~/MasterPage.master"%>
<%@ Register Assembly="DevExpress.Web.ASPxGridView.v8.1, Version=8.1.6.0, Culture=neutral, PublicKeyToken=79868b8147b5eae4"
Namespace="DevExpress.Web.ASPxGridView" TagPrefix="dxwgv" %>
<%@ Register Assembly="DevExpress.Web.ASPxEditors.v8.1, Version=8.1.6.0, Culture=neutral, PublicKeyToken=79868b8147b5eae4"
Namespace="DevExpress.Web.ASPxEditors" TagPrefix="dxe" %>
<%@ Register Assembly="DevExpress.Web.v8.1, Version=8.1.6.0, Culture=neutral, PublicKeyToken=79868b8147b5eae4"
Namespace="DevExpress.Web.ASPxTabControl" TagPrefix="dxtc" %>
<%@ Register Assembly="DevExpress.Web.v8.1, Version=8.1.6.0, Culture=neutral, PublicKeyToken=79868b8147b5eae4"
Namespace="DevExpress.Web.ASPxClasses" TagPrefix="dxw" %>
<%@ Register Assembly="DevExpress.Web.v8.1, Version=8.1.6.0, Culture=neutral, PublicKeyToken=79868b8147b5eae4"
Namespace="DevExpress.Web.ASPxPopupControl" TagPrefix="dxpc" %>
<asp:Content ContentPlaceHolderID="ContentPlaceHolder1" ID="CC" runat="Server">
<br />
<dxwgv:aspxgridview id="ASPxGridView1" runat="server" autogeneratecolumns="False"
clientinstancename="grid" datasourceid="AccessDataSource1" keyfieldname="CategoryID"
onsummarydisplaytext="ASPxGridView1_SummaryDisplayText" width="552px">
<Settings ShowFooter="True"></Settings>
<TotalSummary>
<dxwgv:ASPxSummaryItem SummaryType="Sum" FieldName="CategoryID" ShowInColumn="CategoryID"></dxwgv:ASPxSummaryItem>
</TotalSummary>
<Columns>
<dxwgv:GridViewDataTextColumn FieldName="CategoryID" ReadOnly="True" VisibleIndex="0">
<EditFormSettings Visible="False"></EditFormSettings>
</dxwgv:GridViewDataTextColumn>
<dxwgv:GridViewDataTextColumn FieldName="CategoryName" VisibleIndex="1"></dxwgv:GridViewDataTextColumn>
<dxwgv:GridViewDataTextColumn FieldName="Description" VisibleIndex="2"></dxwgv:GridViewDataTextColumn>
</Columns>
</dxwgv:aspxgridview><br />
<dxe:ASPxSpinEdit ID="ASPxSpinEdit1" runat="server" Height="21px" Number="0">
<ClientSideEvents NumberChanged="function(s, e) {
grid.PerformCallback();
}" />
</dxe:ASPxSpinEdit>
<asp:AccessDataSource ID="AccessDataSource1" runat="server" DataFile="~/App_Data/nwind.mdb"
SelectCommand="SELECT * FROM [Categories]"></asp:AccessDataSource>
</asp:Content>
Imports Microsoft.VisualBasic
Imports System
Imports System.Data
Imports System.Configuration
Imports System.Collections
Imports System.Web
Imports DevExpress.Web.ASPxEditors
Imports DevExpress.Web.ASPxGridView
Imports System.Web.UI.WebControls
Partial Public Class _Default
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
End Sub
Protected Sub ASPxGridView1_SummaryDisplayText(ByVal sender As Object, ByVal e As ASPxGridViewSummaryDisplayTextEventArgs)
If e.Item.FieldName = "CategoryID" Then
e.Text = String.Format("Sum = {0}", Convert.ToDouble(e.Value) * Convert.ToDouble(ASPxSpinEdit1.Value))
End If
End Sub
End Class
<%@ Page Language="vb" AutoEventWireup="true" CodeFile="Default.aspx.vb" Inherits="_Default" MasterPageFile="~/MasterPage.master"%>
<%@ Register Assembly="DevExpress.Web.ASPxGridView.v8.1, Version=8.1.6.0, Culture=neutral, PublicKeyToken=9B171C9FD64DA1D1"
Namespace="DevExpress.Web.ASPxGridView" TagPrefix="dxwgv" %>
<%@ Register Assembly="DevExpress.Web.ASPxEditors.v8.1, Version=8.1.6.0, Culture=neutral, PublicKeyToken=9B171C9FD64DA1D1"
Namespace="DevExpress.Web.ASPxEditors" TagPrefix="dxe" %>
<%@ Register Assembly="DevExpress.Web.v8.1, Version=8.1.6.0, Culture=neutral, PublicKeyToken=9B171C9FD64DA1D1"
Namespace="DevExpress.Web.ASPxTabControl" TagPrefix="dxtc" %>
<%@ Register Assembly="DevExpress.Web.v8.1, Version=8.1.6.0, Culture=neutral, PublicKeyToken=9B171C9FD64DA1D1"
Namespace="DevExpress.Web.ASPxClasses" TagPrefix="dxw" %>
<%@ Register Assembly="DevExpress.Web.v8.1, Version=8.1.6.0, Culture=neutral, PublicKeyToken=9B171C9FD64DA1D1"
Namespace="DevExpress.Web.ASPxPopupControl" TagPrefix="dxpc" %>
<asp:Content ContentPlaceHolderID="ContentPlaceHolder1" ID="CC" runat="Server">
<br />
<dxwgv:aspxgridview id="ASPxGridView1" runat="server" autogeneratecolumns="False"
clientinstancename="grid" datasourceid="AccessDataSource1" keyfieldname="CategoryID"
onsummarydisplaytext="ASPxGridView1_SummaryDisplayText" width="552px">
<Settings ShowFooter="True"></Settings>
<TotalSummary>
<dxwgv:ASPxSummaryItem SummaryType="Sum" FieldName="CategoryID" ShowInColumn="CategoryID"></dxwgv:ASPxSummaryItem>
</TotalSummary>
<Columns>
<dxwgv:GridViewDataTextColumn FieldName="CategoryID" ReadOnly="True" VisibleIndex="0">
<EditFormSettings Visible="False"></EditFormSettings>
</dxwgv:GridViewDataTextColumn>
<dxwgv:GridViewDataTextColumn FieldName="CategoryName" VisibleIndex="1"></dxwgv:GridViewDataTextColumn>
<dxwgv:GridViewDataTextColumn FieldName="Description" VisibleIndex="2"></dxwgv:GridViewDataTextColumn>
</Columns>
</dxwgv:aspxgridview><br />
<dxe:ASPxSpinEdit ID="ASPxSpinEdit1" runat="server" Height="21px" Number="0">
<ClientSideEvents NumberChanged="function(s, e) {
grid.PerformCallback();
}" />
</dxe:ASPxSpinEdit>
<asp:AccessDataSource ID="AccessDataSource1" runat="server" DataFile="~/App_Data/nwind.mdb"
SelectCommand="SELECT * FROM [Categories]"></asp:AccessDataSource>
</asp:Content>
Imports Microsoft.VisualBasic
Imports System
Imports System.Data
Imports System.Configuration
Imports System.Collections
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports System.Web.UI.HtmlControls
Partial Public Class MasterPage
Inherits System.Web.UI.MasterPage
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
End Sub
End Class
See Also