Back to Devexpress

ASPxGridViewSummaryDisplayTextEventArgs.Item Property

aspnet-devexpress-dot-web-dot-aspxgridviewsummarydisplaytexteventargs.md

latest3.0 KB
Original Source

ASPxGridViewSummaryDisplayTextEventArgs.Item Property

Gets the processed summary item.

Namespace : DevExpress.Web

Assembly : DevExpress.Web.v25.2.dll

NuGet Package : DevExpress.Web

Declaration

csharp
public ASPxSummaryItem Item { get; }
vb
Public ReadOnly Property Item As ASPxSummaryItem

Property Value

TypeDescription
ASPxSummaryItem

An ASPxSummaryItem object that represents the processed summary item.

|

Remarks

Example

The following example illustrates how to use the Item property.

Web Forms approach:

aspx
<dx:ASPxGridView ID="ASPxGridView1" runat="server" AutoGenerateColumns="False"
        ClientInstanceName="grid" DataSourceId="AccessDataSource1" KeyFieldName="CategoryID"        
        OnSummaryDisplayText="ASPxGridView1_SummaryDisplayText" Width="552px">
    <Settings ShowFooter="True" />
    <TotalSummary>
        <dx:ASPxSummaryItem SummaryType="Sum" FieldName="CategoryID" ShowInColumn="CategoryID" />
    </TotalSummary>
    <Columns>
        <dx:GridViewDataTextColumn FieldName="CategoryID" ReadOnly="True" ">
            <EditFormSettings Visible="False" />
        </dx:GridViewDataTextColumn>
        <dx:GridViewDataTextColumn FieldName="CategoryName" />
        <dx:GridViewDataTextColumn FieldName="Description" />
    </Columns>
</dx:ASPxGridView>
csharp
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));
}

MVC approach:

cshtml
Html.DevExpress().GridView(settings => {
    settings.Name = "dxGridView";
    ...
    settings.GroupSummary.Add(DevExpress.Data.SummaryItemType.Count, "ShipName");
    settings.TotalSummary.Add(DevExpress.Data.SummaryItemType.Sum, "UnitPrice").DisplayFormat = "c";
    settings.SummaryDisplayText = (sender, e) => {
        if(e.Item.FieldName == "UnitPrice")
            e.Text = string.Format("Sum of unit price: ${0}", Convert.ToDouble(e.Value));
        if(e.Item.FieldName == "ShipName")
            e.Text = string.Format("Count of records: {0}", Convert.ToDouble(e.Value));
    };
})
.Bind(Model)
.Render();

See Also

ASPxGridViewSummaryDisplayTextEventArgs Class

ASPxGridViewSummaryDisplayTextEventArgs Members

DevExpress.Web Namespace