Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

TcxDataSummaryItems Class

The base class for summary item collections.

#Declaration

Delphi
TcxDataSummaryItems = class(
    TcxCollection
)

#Remarks

A summary controller uses summary item collections to manage group and footer summaries.

VCL Data Controller: Group and Footer Summary Items

#Main API Members

The list below outlines key members of the TcxDataSummaryItems class. These members allow you to manage and configure summary items.

#Collection Management APIs

Add
Creates a new summary item and adds it to the collection.
Clear
Clears the collection.
Count
Returns the number of stored summary items.
Delete | DeleteItems
Delete individual summary items.
FindByTag
Returns the first summary item in the collection with the specified tag.
Items
Provides indexed access to summary items in the collection.
DefaultFormat
Returns the default formatting pattern for the summary item with the specified data type, position, and calculation algorithm.
OnSummary
Allows you to customize summary calculation.

#General-Purpose API Members

Assign
Copies settings and stored items between summary item collections.
BeginUpdate | EndUpdate
Allow you to avoid excessive notifications and corresponding redraw operations during batch collection changes.
DataController | Summary
Provide access to parent data and summary controllers.

#Terminal TcxDataSummaryItems Class Descendants

Do not use the TcxDataSummaryItems class directly. Use the following descendants instead:

TcxDataFooterSummaryItems
A collection of footer summaries.
TcxDataGroupSummaryItems
A collection of group summaries.

#Indirect TcxDataSummaryItems Class Reference

The TcxDataSummaryItem.SummaryItems property references the TcxDataFooterSummaryItems or TcxDataGroupSummaryItems class as a TcxDataSummaryItems object.

The code example in this section creates and displays three summary items for the same column. These items use three different predefined summary calculation algorithmsSUM, MAX, and MIN.

How to Test this Code Example

Follow the steps below to test this code example in your RAD Studio IDE:

  1. Copy the DFM code snippet below.
  2. Create a new project in the IDE and focus an empty form.
  3. Press Ctrl+V to populate the form with preconfigured components.
  4. Select the form and create an empty OnCreate event handler, paste the code example, and run the project.
object cxGrid1: TcxGrid
   Left = 72
   Top = 80
   Width = 425
   Height = 321
   TabOrder = 0
   object cxGrid1DBTableView1: TcxGridDBTableView
     Navigator.Buttons.CustomButtons = <>
     ScrollbarAnnotations.CustomAnnotations = <>
     DataController.DataSource = DataSource1
     DataController.Summary.DefaultGroupSummaryItems = <>
     DataController.Summary.FooterSummaryItems = <>
     DataController.Summary.SummaryGroups = <>
     object cxGrid1DBTableView1RecId: TcxGridDBColumn
       DataBinding.FieldName = 'RecId'
       Visible = False
     end
     object cxGrid1DBTableView1Groups: TcxGridDBColumn
       DataBinding.FieldName = 'Groups'
     end
     object cxGrid1DBTableView1Names: TcxGridDBColumn
       DataBinding.FieldName = 'Names'
     end
     object cxGrid1DBTableView1Values: TcxGridDBColumn
       DataBinding.FieldName = 'Values'
       Width = 175
     end
   end
   object cxGrid1Level1: TcxGridLevel
     GridView = cxGrid1DBTableView1
   end
 end
 object dxMemData1: TdxMemData
   Active = True
   Indexes = <>
   Persistent.Data = {
     5665728FC2F5285C8FFE3F04000000140000000100070047726F757073001400
     0000010006004E616D657300040000000300070056616C756573000400000009
     000600446174657300010600000047726F75703101050000004E616D6531010A
     000000017B000B00010600000047726F75703101050000004E616D6532011400
     000001CF0E0B00010600000047726F75703201050000004E616D6533011E0000
     00017A210B00010600000047726F75703201050000004E616D65340128000000
     01892B0B00}
   SortOptions = []
   Left = 248
   Top = 336
   object dxMemData1Groups: TStringField
     FieldName = 'Groups'
   end
   object dxMemData1Names: TStringField
     FieldName = 'Names'
   end
   object dxMemData1Values: TIntegerField
     FieldName = 'Values'
   end
   object dxMemData1Dates: TDateField
     FieldName = 'Dates'
   end
 end
 object DataSource1: TDataSource
   DataSet = dxMemData1
   Left = 152
   Top = 320
 end
 object dxSkinController1: TdxSkinController
   SkinName = 'WXICompact'
   SkinPaletteName = 'Office Dark Gray'
   Left = 64
   Top = 320
 end
procedure TMyForm.FormCreate(Sender: TObject);
var
  ASummary: TcxDataSummary;
  ASummaryItem: TcxGridDBTableSummaryItem;
begin
  cxGrid1DBTableView1.OptionsView.Footer := True; // Displays a footer
  cxGrid1DBTableView1.OptionsView.FooterMultiSummaries := True;  // Allows the footer to fit all summaries
  ASummary := cxGrid1DBTableView1.DataController.Summary;
  ASummary.BeginUpdate;  // Initiates the following batch change
  try
    // Create three summary items
    ASummaryItem := ASummary.FooterSummaryItems.Add as TcxGridDBTableSummaryItem;
    ASummaryItem.Column := cxGrid1DBTableView1Values;  // Associates the summary with the "Values" column
    ASummaryItem.Kind := skSum;  // Sums all values in the target column
    ASummaryItem := ASummary.FooterSummaryItems.Add as TcxGridDBTableSummaryItem;
    ASummaryItem.Column := cxGrid1DBTableView1Values;  // Associates the summary with the "Values" column
    ASummaryItem.Kind := skMax;  // Displays the highest value in the target column
    ASummaryItem := ASummary.FooterSummaryItems.Add as TcxGridDBTableSummaryItem;
    ASummaryItem.Column := cxGrid1DBTableView1Values;  // Associates the summary with the "Values" column
    ASummaryItem.Kind := skMin;  // Displays the minimum value in the target column
  finally
    ASummary.EndUpdate;  // Calls EndUpdate regardless of the batch operation's success
  end;
end;

VCL Data Grid: Three Different Footer Summaries for the Same Column

To see group and footer summaries in action, run the Grid and Data Editors demo in the VCL Demo Center installed with compiled DevExpress demos. Click Data Summaries or Advanced Data Filtering in the sidebar to select the corresponding VCL Data Grid demo.

Download: Compiled VCL Demos

Tip

Compiled DevExpress demos ship with source code installed in the Public Documents folder (%Public%) for all users (default). You can find all project and source code files for the Data Grid demo in the following folder:

%Public%\Documents\DevExpress VCL Demos\MegaDemos\Product Demos\ExpressQuantumGrid

#Inheritance

See Also