Back to Devexpress

SummaryItemBase.FieldName Property

wpf-devexpress-dot-xpf-dot-grid-dot-summaryitembase-da4cb621.md

latest7.8 KB
Original Source

SummaryItemBase.FieldName Property

Gets or sets the name of a data source field whose values are used for summary calculation. This is a dependency property.

Namespace : DevExpress.Xpf.Grid

Assembly : DevExpress.Xpf.Grid.v25.2.Core.dll

NuGet Package : DevExpress.Wpf.Grid.Core

Declaration

csharp
public string FieldName { get; set; }
vb
Public Property FieldName As String

Property Value

TypeDescription
String

A String value that specifies the name of the data source field whose values are used for summary calculation.

|

Example

The following example shows how to calculate group summaries and display them within group rows. A group summary is a value of the aggregate function calculated over all data rows within a group. The GridControl‘s GroupSummary collection stores group summary items.

This example uses the GridControl.CustomSummaryExists event to calculate group summaries only for the top group level:

View Example: How to Display Group Summaries

xaml
<dxg:GridControl x:Name="grid" CustomSummaryExists="OnCustomSummaryExists">
    <dxg:GridControl.View>
        <dxg:TableView AutoWidth="True"/>
    </dxg:GridControl.View>
    <dxg:GridControl.Columns>
        <dxg:GridColumn FieldName="UserName" />
        <dxg:GridColumn FieldName="RegistrationDate" />
        <dxg:GridColumn FieldName="Married" GroupIndex="0" SortOrder="Ascending" />
        <dxg:GridColumn FieldName="Age" />
    </dxg:GridControl.Columns>
    <dxg:GridControl.GroupSummary>
        <dxg:GridSummaryItem FieldName="Age" SummaryType="Min"/>
        <dxg:GridSummaryItem FieldName="Age" SummaryType="Max"/>
    </dxg:GridControl.GroupSummary>
</dxg:GridControl>
csharp
void OnCustomSummaryExists(object sender, CustomSummaryExistEventArgs e) {
    e.Exists = e.GroupLevel == 0;
}
vb
Private Sub OnCustomSummaryExists(ByVal sender As Object, ByVal e As CustomSummaryExistEventArgs)
    e.Exists = e.GroupLevel = 0
End Sub

The following code snippets (auto-collected from DevExpress Examples) contain references to the FieldName property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

wpf-data-grid-process-frequent-data-updates/CS/ChunkAndOptSummariesExample/MainWindow.xaml#L18

xml
<dxg:GridControl.TotalSummary>
    <dxg:GridSummaryItem SummaryType="Count" FieldName="Name" DisplayFormat="Total count: {0:N0}"/>
</dxg:GridControl.TotalSummary>

wpf-data-grid-display-group-summaries/CS/DisplayGroupSummaries_CodeBehind/MainWindow.xaml#L19

xml
<dxg:GridControl.GroupSummary>
    <dxg:GridSummaryItem FieldName="Age" SummaryType="Min"/>
    <dxg:GridSummaryItem FieldName="Age" SummaryType="Max"/>

wpf-data-grid-summarize-empty-cells/CS/CustomSummary_EmptyCells_CodeBehind/MainWindow.xaml#L23

xml
<dxg:GridSummaryItem DisplayFormat="Total empty cells count: {0}"
                     FieldName="Number"
                     SummaryType="Custom" />

wpf-tree-list-calculate-custom-node-summaries/CS/CustomNodeSummaries_CodeBehind/MainWindow.xaml#L18

xml
<dxg:TreeListView.NodeSummary>
    <dxg:TreeListSummaryItem FieldName="Statistics" SummaryType="Custom"/>
</dxg:TreeListView.NodeSummary>

wpf-data-grid-bind-to-pagedasyncsource/CS/PagedAsyncSourceSample/MainWindow.xaml#L31

xml
<dxg:GridSummaryItem SummaryType="Count" Alignment="Right"/>
    <dxg:GridSummaryItem SummaryType="Max" FieldName="Created" DisplayFormat="{}Last created: {0}" Alignment="Right"/>
</dxg:GridControl.TotalSummary>

wpf-data-grid-summarize-empty-cells/CS/CustomSummary_EmptyCells_CodeBehind/MainWindow.xaml.cs#L34

csharp
void OnCustomSummary(object sender, CustomSummaryEventArgs e) {
    if(((GridSummaryItem)e.Item).FieldName != "Number")
        return;

wpf-tree-list-calculate-custom-node-summaries/CS/CustomNodeSummaries_CodeBehind/MainWindow.xaml.cs#L24

csharp
void OnCustomSummary(object sender, TreeListCustomSummaryEventArgs e) {
    if(e.IsNodeSummary && e.SummaryItem.FieldName == "Statistics") {
        if(e.SummaryProcess == CustomSummaryProcess.Calculate) {

wpf-data-grid-summarize-empty-cells/VB/CustomSummary_EmptyCells_CodeBehind/MainWindow.xaml.vb#L30

vb
Private Sub OnCustomSummary(ByVal sender As Object, ByVal e As CustomSummaryEventArgs)
    If Not Equals(CType(e.Item, GridSummaryItem).FieldName, "Number") Then Return
    If e.SummaryProcess = CustomSummaryProcess.Start Then

wpf-tree-list-calculate-custom-node-summaries/VB/CustomNodeSummaries_CodeBehind/MainWindow.xaml.vb#L33

vb
Private Sub OnCustomSummary(ByVal sender As Object, ByVal e As TreeListCustomSummaryEventArgs)
    If e.IsNodeSummary AndAlso Equals(e.SummaryItem.FieldName, "Statistics") Then
        If e.SummaryProcess = CustomSummaryProcess.Calculate Then

See Also

SummaryItemBase Class

SummaryItemBase Members

DevExpress.Xpf.Grid Namespace