Lesson 5 - Display Summaries

  • 2 minutes to read

This tutorial demonstrates how to display summaries for groups of rows (group summary) or individual data columns (total summary). The tutorial is based on Lesson 4.

The GridControl can calculate the following summaries:

  • the number of data rows (Count);
  • the maximum and minimum values (Max and Min);
  • the sum and the average value (Sum and Average);
  • custom summaries.

Total Summary

Design Time

  1. Invoke the GridControl's smart tag menu.
  2. Click Show Feature Browser:

  3. In the Feature Browser window, open the Total Summaries tab.

  4. Uncheck Show Total Summary and check Show Fixed Total Summary:

  5. Add a summary item to the GridControl.

  6. Specify the FieldName and SummaryType properties.
  7. Set the Alignment property to Left to display the summary on the left side of the Fixed Summary Panel:

Runtime

  1. Set the DataViewBase.ShowFixedTotalSummary property to true to show the Fixed Summary Panel.
  2. Create a GridSummaryItem object and assign it to the GridControl.TotalSummary collection.
  3. Specify the SummaryItemBase.FieldName and SummaryItemBase.SummaryType properties to apply the summary.
  4. Set the SummaryItemBase.Alignment property to Left to display the summary on the left side of the Fixed Summary Panel:

    <dxg:GridControl ItemsSource="{Binding Orders}">
        <dxg:GridControl.TotalSummary>
            <dxg:GridSummaryItem FieldName="OrderId" 
                                 SummaryType="Count"
                                 Alignment="Left"/>
        </dxg:GridControl.TotalSummary>
        <dxg:GridControl.View>
            <dxg:TableView ShowFixedTotalSummary="True" ... />
        </dxg:GridControl.View>
    </dxg:GridControl>
    

Group Summary

Design Time

  1. Invoke the GridControl's smart tag menu.
  2. Click Show Feature Browser:

  3. In the Feature Browser window, open the Group Summaries tab.

  4. Add a summary item to the GridControl.
  5. Specify the FieldName and SummaryType properties.
  6. Specify the DisplayFormat property to display the group summary in the currency format:

Runtime

  1. Create a GridSummaryItem object and assign it to the GridControl.GroupSummary collection.
  2. Specify the SummaryItemBase.FieldName and SummaryItemBase.SummaryType properties to apply the summary.
  3. Specify the SummaryItemBase.DisplayFormat property to display the group summary in the currency format:

    <dxg:GridControl ItemsSource="{Binding Orders}">
        <dxg:GridControl.GroupSummary>
            <dxg:GridSummaryItem FieldName="Freight" SummaryType="Sum" 
                                 DisplayFormat="Sum of Freight is {0:c}"/>
        </dxg:GridControl.GroupSummary>
    </dxg:GridControl>
    

For information on how end users can create and customize data summaries, refer to the following help topic: Edit Summaries.

See Also