Dim band As UltraGridBand = Me.ultraGrid1.DisplayLayout.Bands(0)
' Add a summary of type External.
Dim summary As SummarySettings = band.Summaries.Add(SummaryType.External, band.Columns("ID"))
This topic explains, with code examples, the most common tasks related to performing external summary calculations in the UltraGrid™ control.
The following table lists the topics required as a prerequisite to understanding this topic.
This topic contains the following sections:
Enabling External Summary Calculations
Overview
Property settings
Code
Implementing External Summary Calculations – Conceptual Overview
Overview
Property settings
Implementing External Summary Calculations –Code Example
Description
Preview
Code
Implementing External Summary Calculations on the Summary Calculator – Conceptual Overview
Overview
Property settings
Implementing External Summary Calculations on the Summary Calculator – Code Example
Description
Preview
Code
Related Content
The following table lists the configurable aspects of the WinGrid control. Additional details are available after the summary table.
To enable external summary calculations, the summary type must be set to External on the summaries collection for the specific Band. With the external summary calculation functionality, the UltraGrid control’s summary calculation logic is bypassed that ends up iterating the rows collection to calculate the summary value and will also avoid requesting all of the data to be loaded. This provides the ability to add summaries to the UltraGrid control as well as load data on demand.
The following table maps the desired configuration to property setting.
The following sample code sets the Summary type to External using the Add method on the Summaries collection.
In Visual Basic:
Dim band As UltraGridBand = Me.ultraGrid1.DisplayLayout.Bands(0)
' Add a summary of type External.
Dim summary As SummarySettings = band.Summaries.Add(SummaryType.External, band.Columns("ID"))
In C#:
UltraGridBand band = this.ultraGrid1.DisplayLayout.Bands[0];
// Add a summary of type External.
SummarySettings summary = band.Summaries.Add( SummaryType.External, band.Columns["ID"] );
When the summary type is set to External, the ExternalSummaryValueRequested event is fired. This event exposes a SetExternalSummaryValue method that is used to set the summary value directly or externally.
The following table maps the desired configuration to property setting.
The code example that follows demonstrates the UltraGrid control displaying the external summary value as a result of the following setting:
Following is preview of the external summary value being displayed as a result of implementing the sample code.
The following sample code sets the Summary externally or directly within the ExternalSummaryCalculated event.
In Visual Basic:
Private Sub ultraGrid1_ExternalSummaryValueRequested(sender As Object, e As ExternalSummaryValueEventArgs)
e.SummaryValue.SetExternalSummaryValue("90")
End Sub
In C#:
private void ultraGrid1_ExternalSummaryValueRequested(object sender, ExternalSummaryValueEventArgs e)
{
e.SummaryValue.SetExternalSummaryValue("90");
}
Summaries (Average, Count, Maximum, Minimum and Sum) on the Summary Calculator can also be calculated externally. This is achieved by setting the UseExternalSummaryCalculator property to true. This property is available on UltraGrid.Override
as well as on a particular Band.Override
. When this property is set to True, UltraGrid will cease summary calculations and fire the ExternalSummaryValueRequested event, requesting the value to place in the summary.
The following table maps the desired configuration to property setting.
The ode example that follows demonstrates the UltraGrid control displaying external summary value on the Summary Calculator as a result of the following setting:
The following snapshot demonstrates the effect of the settings listed in the Example text block: the UltraGrid displaying external Summary value on the Summary Calculator for a child band.
The following sample code sets the Summary Calculator to External. The UseExternalSummaryCalculator property is set to True
. UltraGrid displays external summary value on Summary Calculator for child band. The summary value is set within the ExternalSummaryValueRequested event.
In Visual Basic:
' Allow summary calculator to calculate summaries externally for the entire Grid
' this.ultraGrid1.DisplayLayout.Override.UseExternalSummaryCalculator = DefaultableBoolean.True;
' Allows Summary Calculator to calculate summaries externally for a specific band(Bands[1]).
' UltraGrid summary calcuation is stopped and 'ultraGrid1_ExternalSummaryValueRequested event is fired.
Me.ultraGrid1.DisplayLayout.Bands(1).Override.UseExternalSummaryCalculator = Infragistics.Win.DefaultableBoolean.True
Private Sub ultraGrid1_ExternalSummaryValueRequested(sender As Object, e As ExternalSummaryValueEventArgs)
Select Case e.SummaryValue.SummarySettings.SummaryType.ToString()
Case "Count"
e.SummaryValue.SetExternalSummaryValue(5)
Exit Select
Case "Maximum"
e.SummaryValue.SetExternalSummaryValue(100)
Exit Select
End Select
End Sub
In C#:
// Allow summary calculator to calculate summaries externally for the entire // Grid
// this.ultraGrid1.DisplayLayout.Override.UseExternalSummaryCalculator =
// DefaultableBoolean.True;
// Allows Summary Calculator to calculate summaries externally for a specific
// band(Bands[1]).
// UltraGrid summary calcuation is stopped and
// ultraGrid1_ExternalSummaryValueRequested event is fired.
this.ultraGrid1.DisplayLayout.Bands[1].Override.UseExternalSummaryCalculator =
Infragistics.Win.DefaultableBoolean.True;
private void ultraGrid1_ExternalSummaryValueRequested(object sender, ExternalSummaryValueEventArgs e)
{
switch (e.SummaryValue.SummarySettings.SummaryType.ToString())
{
case "Count":
e.SummaryValue.SetExternalSummaryValue(5);
break;
case "Maximum":
e.SummaryValue.SetExternalSummaryValue(100);
break;
}
}
The following topics provide additional information related to this topic.