TcxGridTableOptionsView.FooterMultiSummaries Property
#Declaration
property FooterMultiSummaries: Boolean read; write; default False;
#Property Value
Type | Default | Description |
---|---|---|
Boolean | False |
|
#Remarks
Set the FooterMultiSummaries
property to True
to display multiple footer summaries for a column. To display multiple group footer summaries, set the GroupFooterMultiSummaries property to True
.
Tip
You can call the Can
For example, this function returns False
if the Banded Table View has nested bands regardless of the Footer
property value.
#Code Examples
#Create and Display Three Footer Summaries
The code example in this section creates and displays three summary items for the same column. These items use three different predefined summary calculation algorithms – SUM, MAX, and MIN.
Follow the steps below to test this code example in your RAD Studio IDE:
- Copy the DFM code snippet below.
- Create a new project in the IDE and focus an empty form.
- Press Ctrl+V to populate the form with preconfigured components.
- 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;
#Sum Different Value Types Separately
The code example in this section demonstrates an OnSummary event handler. This handler configures three existing summaries to display sums of positive and negative values as well as the total value.
The grid Table View’s OptionsView.FooterMultiSummaries property is set to True
to display all summary items.
Follow the steps below to test this code example in your RAD Studio IDE:
- Copy the DFM code snippet below.
- Create a new project in the IDE and focus an empty form.
- Press Ctrl+V to populate the form with preconfigured components.
- Select cxGrid1DBTableView1 in the TcxGrid on the form.
- Create an empty OnSummary event handler in the DataController.Summary.FooterSummaryItems node, paste the code example, and run the project.
object cxGrid1: TcxGrid
Left = 8
Top = 8
Width = 441
Height = 278
TabOrder = 0
object cxGrid1DBTableView1: TcxGridDBTableView
Navigator.Buttons.CustomButtons = <>
ScrollbarAnnotations.CustomAnnotations = <>
DataController.DataSource = DataSource1
DataController.Summary.DefaultGroupSummaryItems = <>
DataController.Summary.FooterSummaryItems = <
item
Kind = skSum
Tag = 1
Column = cxGrid1DBTableView1Val
end
item
Kind = skSum
Tag = 2
Column = cxGrid1DBTableView1Val
end
item
Kind = skSum
Column = cxGrid1DBTableView1Val
end>
DataController.Summary.SummaryGroups = <>
OptionsView.Footer = True
OptionsView.FooterMultiSummaries = True
object cxGrid1DBTableView1RecId: TcxGridDBColumn
DataBinding.FieldName = 'RecId'
Width = 84
end
object cxGrid1DBTableView1Desc: TcxGridDBColumn
DataBinding.FieldName = 'Desc'
Width = 190
end
object cxGrid1DBTableView1Val: TcxGridDBColumn
DataBinding.FieldName = 'Val'
Width = 165
end
end
object cxGrid1Level1: TcxGridLevel
GridView = cxGrid1DBTableView1
end
end
object dxMemData1: TdxMemData
Active = True
Indexes = <>
Persistent.Data = {
5665728FC2F5285C8FFE3F020000000A00000001000500446573630002000000
0200040056616C000105000000446573633101FDFF0105000000446573633201
03000105000000446573633301FEFF01050000004465736334010200}
SortOptions = []
Left = 72
Top = 224
object dxMemData1Desc: TStringField
FieldName = 'Desc'
Size = 10
end
object dxMemData1Val: TSmallintField
FieldName = 'Val'
end
end
object DataSource1: TDataSource
DataSet = dxMemData1
Left = 120
Top = 224
end
object dxSkinController1: TdxSkinController
SkinName = 'WXICompact'
SkinPaletteName = 'Clearness'
Left = 192
Top = 224
end
procedure TForm1.cxGrid1DBTableView1DataControllerSummaryFooterSummaryItemsSummary(
ASender: TcxDataSummaryItems; Arguments: TcxSummaryEventArguments;
var OutArguments: TcxSummaryEventOutArguments);
var
ASummaryItem: TcxGridDBTableSummaryItem;
begin
ASummaryItem := Arguments.SummaryItem as TcxGridDBTableSummaryItem;
if ASummaryItem.Column = cxGrid1DBTableView1Val then // Identifies the target column
begin
case ASummaryItem.Tag of // Uses tag values to identify summary items
1: // Calculates the sum of only negative values (the condition excludes zero and positive values)
OutArguments.Done := VarIsNull(OutArguments.Value) or (OutArguments.Value > 0);
2: // Calculates the sum of only positive values (the condition excludes zero and negative values)
OutArguments.Done := VarIsNull(OutArguments.Value) or (OutArguments.Value < 0);
end;
end;
end;
#Default Value
The FooterMultiSummaries
property’s default value is False
.