Class Group
Represents the class that provides a group which defines a set of records that belong to a category. A group has multiple sections such as CaptionSection, SummarySection, GroupsDetailsSection, and RecordsDetailsSection.
Inherited Members
Namespace: Syncfusion.Grouping
Assembly: Syncfusion.Grouping.Base.dll
Syntax
public class Group : Element, IDisposable, IDisposedEvent, IIsDisposedProperty, ITreeTableCounterSource, ITreeTableSummaryArraySource, IContainerElement, IElementTreeTableSource, IElement
Remarks
Groups are created when the records of a table are categorized or when a new record is inserted. Normally, the categories are based on the GroupedColumns but programmers can also provide their own categorization routines by implementing a Comparer for a SortColumnDescriptor. Before groups are categorized, the records are sorted in the order as specified by GroupedColumns. After the records are sorted, the Table object loops through all records to determine the categories records belong to.
Another collection in the TableDescriptor that defines categorization is the RelationChildColumns collection. RelationChildColumns will be added when there is a parent-child relation between two tables. The child table of such a relation must be sorted by the columns that are used to identify a record. These columns match the foreign key columns of the parent table. For every new category key with regards to RelationChildColumns a ChildTable is created. The ChildTable class is derived from the Group.
A group can either be a final node with records or it can be a node with nested groups. If a group has records, its Groups collection will be empty and the Records collection will contain all records. If a group has nested groups, its Groups collection will have the nested groups and the Records collection will be empty.
A group can be expanded and collapsed with its IsExpanded property. Expansion of groups will show or hide nested elements of the group within the DisplayElements collection.
A table has at least one group. The TopLevelGroup is a ChildTable which is derived from Group.
The GroupLevel property will return the group level how deep the group is nested.
Constructors
Group(Element)
Initializes a new instance of the Group class with the specified parent.
Declaration
public Group(Element parent)
Parameters
Type | Name | Description |
---|---|---|
Element | parent | An instance of the Element class. |
Properties
CachedVisibleCount
Gets or sets the cached visible count.
Declaration
public int CachedVisibleCount { get; set; }
Property Value
Type |
---|
System.Int32 |
CachedVisibleCustomCount
Get or sets the cached visible custom count.
Declaration
public double CachedVisibleCustomCount { get; set; }
Property Value
Type |
---|
System.Double |
CachedVisibleItemCount
Gets or sets the cached visible item count.
Declaration
public int CachedVisibleItemCount { get; set; }
Property Value
Type |
---|
System.Int32 |
CachedYamountCount
Gets or sets the cached element row height.
Declaration
public double CachedYamountCount { get; set; }
Property Value
Type |
---|
System.Double |
Caption
Gets the CaptionSection of this group.
Declaration
public CaptionSection Caption { get; }
Property Value
Type |
---|
CaptionSection |
Category
Gets the main category key of this group.
Declaration
public object Category { get; }
Property Value
Type |
---|
System.Object |
CategoryColumns
Gets the columns that defines the category of the group.
Declaration
public SortColumnDescriptorCollection CategoryColumns { get; }
Property Value
Type |
---|
SortColumnDescriptorCollection |
CategoryForeignKeyParentIds
Gets or sets the collection of foreign key parent ids associated with category keys for this group when the table is grouped by the display member of a foreign key relation. Child tables can have more than one category key if multiple relation keys were specified in the RelationDescriptor.
Declaration
public object[] CategoryForeignKeyParentIds { get; set; }
Property Value
Type |
---|
System.Object[] |
CategoryKeys
Gets or sets the collection of category keys for this group. Child tables can have more than one category key if multiple relation keys were specified in the RelationDescriptor.
Declaration
public object[] CategoryKeys { get; set; }
Property Value
Type |
---|
System.Object[] |
Details
Gets the DetailsSection of this group.
Declaration
public DetailsSection Details { get; }
Property Value
Type |
---|
DetailsSection |
FilteredChildNodeCount
Gets the number of direct child elements either records or nested groups in the group.
Declaration
public int FilteredChildNodeCount { get; }
Property Value
Type |
---|
System.Int32 |
FilteredRecords
Gets the filtered records from the FilteredRecordsInDetailsCollection that meets the filter criteria.
Declaration
public FilteredRecordsInDetailsCollection FilteredRecords { get; }
Property Value
Type |
---|
FilteredRecordsInDetailsCollection |
Remarks
ShortCut for ((RecordsDetails) Details).FilteredRecords. This returns only records in the group that meet filter criteria.
FlattenedFilteredRecords
Gets the flattened collection of filtered records that belong to this group and nested groups.
Declaration
public FlattenedFilteredRecordsInGroupCollection FlattenedFilteredRecords { get; }
Property Value
Type |
---|
FlattenedFilteredRecordsInGroupCollection |
FlattenedRecords
Gets a flattened collection of records that belong to this group and nested groups.
Declaration
public FlattenedRecordsInGroupCollection FlattenedRecords { get; }
Property Value
Type |
---|
FlattenedRecordsInGroupCollection |
Groups
Gets the collection of records from the GroupsInDetailsCollection.
Declaration
public GroupsInDetailsCollection Groups { get; }
Property Value
Type |
---|
GroupsInDetailsCollection |
Remarks
ShortCut for ((GroupsDetails) Details).Groups. A group can either be a final node with records or it can be a node with nested groups. If a group has records, its Groups collection will be empty and the Records collection will contain all records. If a group has nested groups, its Groups collection will have the nested groups and the Records collection will be empty.
GroupTypedListRecords
Gets a group typed list collection of records that belong to this group and nested groups.
Declaration
public GroupTypedListRecordsCollection GroupTypedListRecords { get; }
Property Value
Type |
---|
GroupTypedListRecordsCollection |
Id
Gets or set the group id.
Declaration
public override int Id { get; set; }
Property Value
Type |
---|
System.Int32 |
Overrides
IsCollapsible
Gets a value indicating whether the groups can be collapsed or not.
Declaration
public virtual bool IsCollapsible { get; }
Property Value
Type |
---|
System.Boolean |
IsExpanded
Gets or sets the value indicating whether the groups are in expanded state or not.
Declaration
public virtual bool IsExpanded { get; set; }
Property Value
Type |
---|
System.Boolean |
IsMainGroup
Gets the value indicating whether this is the root group of the table. A TopLevelGroup is the root group.
Declaration
public bool IsMainGroup { get; }
Property Value
Type |
---|
System.Boolean |
IsTopLevelGroup
Gets a value indicating whether this is the TopLevelGroup or not.
Declaration
public virtual bool IsTopLevelGroup { get; }
Property Value
Type |
---|
System.Boolean |
Name
Gets the name of the column by which the group is categorized.
Declaration
public virtual string Name { get; }
Property Value
Type |
---|
System.String |
Remarks
see GroupedColumns.
OldCaptionText
Get or sets the old caption text.
Declaration
public string OldCaptionText { get; set; }
Property Value
Type |
---|
System.String |
PassThroughItem
Gets or sets a PassThrough group item.
Declaration
public object PassThroughItem { get; set; }
Property Value
Type |
---|
System.Object |
Records
Gets the records of the RecordsInDetailsCollection irrespective of the records that meets filter criteria.
Declaration
public RecordsInDetailsCollection Records { get; }
Property Value
Type |
---|
RecordsInDetailsCollection |
Remarks
ShortCut for ((RecordsDetails) Details).Records. This returns all records in the group including records that do not meet filter criteria.
Sections
Gets the value of all sections in the group.
Declaration
public SectionInGroupCollection Sections { get; }
Property Value
Type |
---|
SectionInGroupCollection |
SourceList
Gets or sets the list that is associated with this ChildTable.
Declaration
public IList SourceList { get; set; }
Property Value
Type |
---|
System.Collections.IList |
Remarks
The value will only be initialized when you have a UniformChildList relation and Engine.UseOldUniformChildListRelation is false. The list is a reference to the strong-typed nested collection in this child table. The ChildTable listens to ListChanged events on that list if IBindingList interface is implemented. For all other relation kinds this value will always be null.
Summary
Gets the ISummarySection of this group.
Declaration
public ISummarySection Summary { get; }
Property Value
Type |
---|
ISummarySection |
UniqueGroupId
Gets an array of category keys for this group and all parent groups which is used by FilterBarCells and FilterBarSummary to compare whether conditions should be applied to this group.
Declaration
public object[] UniqueGroupId { get; }
Property Value
Type |
---|
System.Object[] |
Methods
BeginInit()
Begins the initialization of sections.
Declaration
public void BeginInit()
CategoriesToString()
Gets a string in format (TableDescriptor.Name) {GetChildCount()}-Items: CategoryKeys.
Declaration
public string CategoriesToString()
Returns
Type | Description |
---|---|
System.String | String with state information about the group. |
CollapseAllGroups()
Collapses this group and all nested groups.
Declaration
public void CollapseAllGroups()
CollapseAllGroups(Boolean)
Collapses all groups and all nested groups and only optionally raises the DisplayElementChanging and DisplayElementChanged events.
Declaration
public void CollapseAllGroups(bool raiseDisplayElementChangeEvents)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | raiseDisplayElementChangeEvents | True if DisplayElementChanging and DisplayElementChanged events should be raised; Otherwise False. |
CollapseAllRecords()
Collapses all records in this group and all nested groups.
Declaration
public void CollapseAllRecords()
CollapseAllRecords(Boolean)
Collapses all records in this group and all nested groups and only optionally raises DisplayElementChanging and DisplayElementChanged events.
Declaration
public void CollapseAllRecords(bool raiseDisplayElementChangeEvents)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | raiseDisplayElementChangeEvents | True if DisplayElementChanging and DisplayElementChanged events should be raised; Otherwise False. |
CreateGroupTypedListRecordsCollection()
Creates the group typed list records collection.
Declaration
protected virtual GroupTypedListRecordsCollection CreateGroupTypedListRecordsCollection()
Returns
Type | Description |
---|---|
GroupTypedListRecordsCollection | An instance of the GroupTypedListRecordsCollection class. |
Dispose(Boolean)
Overridden to manage the unwanted resources.
Declaration
protected override void Dispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | disposing |
Overrides
EndInit()
Ends the initialization of sections.
Declaration
public void EndInit()
ExpandAllGroups()
Expands this group and all nested groups.
Declaration
public void ExpandAllGroups()
ExpandAllGroups(Boolean)
Expands this group and all nested groups and only optionally raises the DisplayElementChanging and DisplayElementChanged events.
Declaration
public void ExpandAllGroups(bool raiseDisplayElementChangeEvents)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | raiseDisplayElementChangeEvents | True if DisplayElementChanging and DisplayElementChanged events should be raised; Otherwise False. |
ExpandAllGroups(Boolean, Boolean)
Expands this group and all nested groups and only optionally raises the DisplayElementChanging and DisplayElementChanged events and only optionally invalidates counters.
Declaration
public void ExpandAllGroups(bool raiseDisplayElementChangeEvents, bool refreshCounters)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | raiseDisplayElementChangeEvents | True if events should be raised. |
System.Boolean | refreshCounters | True if counters should be invalidated. |
ExpandAllRecords(Boolean)
Expands all records in this group and all nested groups and only optionally raises the DisplayElementChanging and DisplayElementChanged events.
Declaration
public void ExpandAllRecords(bool raiseDisplayElementChangeEvents)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | raiseDisplayElementChangeEvents | True if DisplayElementChanging and DisplayElementChanged events should be raised; Otherwise False. |
ExpandAllRecords(Boolean, Boolean)
Expands all records in this group and all nested groups and only optionally raises the DisplayElementChanging and DisplayElementChanged events and only optionally invalidates counters.
Declaration
public void ExpandAllRecords(bool raiseDisplayElementChangeEvents, bool refreshCounters)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | raiseDisplayElementChangeEvents | Specifies if DispalyElementChanged events should be raised. |
System.Boolean | refreshCounters | Specifies if the counters should be invalidated or not. |
FindAddNewRecord()
Finds the AddNewRecord for the group within the AddNewRecordSection.
Declaration
public Record FindAddNewRecord()
Returns
Type | Description |
---|---|
Record | A reference to the AddNewRecord or NULL if group has not such a record. |
GetChildCount()
Overridden to get the child count for a given group.
Declaration
public override int GetChildCount()
Returns
Type | Description |
---|---|
System.Int32 | Child count. |
Overrides
GetChildListPosition()
Gets the position of the first unsorted record in this list in the UnsortedRecords collection.
Declaration
public int GetChildListPosition()
Returns
Type | Description |
---|---|
System.Int32 | If found, position of first unsorted record; Otherwise -1. |
Remarks
The ChildTable must belong to a UniformChildList relation. For other types of relations the function returns -1.
GetCustomCount()
Overridden to get the custom count for the element.
Declaration
public override double GetCustomCount()
Returns
Type | Description |
---|---|
System.Double | Custom count. |
Overrides
GetDefaultValue(FieldDescriptor)
Gets the default value for the specified field taking FieldDescriptor.DefaultValue and category keys of the child group into account.
Declaration
public object GetDefaultValue(FieldDescriptor fieldDescriptor)
Parameters
Type | Name | Description |
---|---|---|
FieldDescriptor | fieldDescriptor | The field descriptor. |
Returns
Type | Description |
---|---|
System.Object | Default value. |
GetElementCount()
Overridden to get the elements count.
Declaration
public override int GetElementCount()
Returns
Type | Description |
---|---|
System.Int32 | Number of elements. |
Overrides
GetFilteredRecordCount()
Overridden to get the filtered records count.
Declaration
public override int GetFilteredRecordCount()
Returns
Type | Description |
---|---|
System.Int32 | Filtered record count. |
Overrides
GetFirstRecord()
Gets for the first record in the group. If the group has nested groups, they will be recursively searched.
Declaration
public Record GetFirstRecord()
Returns
Type | Description |
---|---|
Record | The first record in the group; NULL if group is empty. |
GetFormattedSummaryProperty(SummaryDescriptor, String, String)
Gets the value of the summary with the specified name and formats its output.
Declaration
public string GetFormattedSummaryProperty(SummaryDescriptor sd, string propertyName, string format)
Parameters
Type | Name | Description |
---|---|---|
SummaryDescriptor | sd | A summary of the TableDescriptor.Summaries collection. |
System.String | propertyName | The property in the summary. The value will be determined with reflection and converted to a string. |
System.String | format | The format to be used in System.String and System.String.Format(string,object) for formatting the result, e.g. "{0:c}". See also http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconformattingtypes.asp |
Returns
Type | Description |
---|---|
System.String | The specified property as formatted string. |
GetFormattedSummaryProperty(String, String, String)
Gets the value of the summary with the specified name and formats its output.
Declaration
public string GetFormattedSummaryProperty(string summaryDescriptorName, string propertyName, string format)
Parameters
Type | Name | Description |
---|---|---|
System.String | summaryDescriptorName | A summary of the TableDescriptor and Summaries collection. |
System.String | propertyName | The property in the summary. The value will be determined with reflection and converted to a string. |
System.String | format | The format to be used in System.String and System.String.Format(string,object) for formatting the result, e.g. "{0:c}". See also http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconformattingtypes.asp |
Returns
Type | Description |
---|---|
System.String | The specified property as formatted string. |
GetRecordCount()
Overridden to get the records count.
Declaration
public override int GetRecordCount()
Returns
Type | Description |
---|---|
System.Int32 | Number of records. |
Overrides
GetSummaries(Table, out Boolean)
Overridden to get summary information for this element and child elements.
Declaration
public override ITreeTableSummary[] GetSummaries(Table parentTable, out bool summaryChanged)
Parameters
Type | Name | Description |
---|---|---|
Table | parentTable | A reference to the parent table. |
System.Boolean | summaryChanged | True if changes were detected. |
Returns
Type | Description |
---|---|
ITreeTableSummary[] | Array of summaries. |
Overrides
GetSummary(SummaryDescriptor)
Gets the value of the specified summary.
Declaration
public ITreeTableSummary GetSummary(SummaryDescriptor sd)
Parameters
Type | Name | Description |
---|---|---|
SummaryDescriptor | sd | A summary of the TableDescriptor.Summaries collection. |
Returns
Type | Description |
---|---|
ITreeTableSummary | An object that implements the ITreeTableSummary. You should cast the object to the correct runtime type depending on the SummaryType, e.g. DoubleAggregateSummary in case of a SummaryType.DoubleAggregate |
GetSummary(Int32)
Gets the summary at the specified index.
Declaration
public ITreeTableSummary GetSummary(int indexOfSummaryDescriptor)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | indexOfSummaryDescriptor | The index of the summary in the TableDescriptor.Summaries collection. |
Returns
Type | Description |
---|---|
ITreeTableSummary | An object that implements the ITreeTableSummary. You should cast the object to the correct runtime type depending on the SummaryType, e.g. DoubleAggregateSummary in case of a SummaryType.DoubleAggregate |
Examples
string GetAverageSummary(SummaryDescriptor summaryDescriptor, Group group)
{
Table table = group.ParentTable;
TableDescriptor td = table.TableDescriptor;
string summaryText = "";
bool use31Code = true;
if (use31Code)
{
// Option 1: Strong typed access to DoubleAggregateSummary.
DoubleAggregateSummary summary1 = (DoubleAggregateSummary) group.GetSummary(summaryDescriptor);
summaryText = string.Format("{0:c}", summary1.Average);
// or Option 2: Use reflection to get "Average" property of summary
summaryText = string.Format("{0:c}", group.GetSummaryProperty(summaryDescriptor, "Average"));
// or Option 3: Use reflection to get "Average" property of summary and format it
summaryText = group.GetFormattedSummaryProperty(summaryDescriptor, "Average", "{0:c}");
}
else
{
// This is the code you had to use in version 3.0 and earlier (still working but bit more complicate)
if (summaryDescriptor != null)
{
int indexOfSd1 = table.TableDescriptor.Summaries.IndexOf(summaryDescriptor);
// strong typed - you have to cast to DoubleAggregateSummary.
DoubleAggregateSummary summary1 = (DoubleAggregateSummary) group.GetSummaries(table)[indexOfSd1];
summaryText = string.Format("{0:c}", summary1.Average);
}
}
return summaryText;
}
Function GetAverageSummary(ByVal summaryDescriptor As SummaryDescriptor, ByVal group As Group) As String
Dim table As Table = group.ParentTable
Dim td As TableDescriptor = table.TableDescriptor
Dim summaryText As String = ""
Dim use31Code As Boolean = True
If use31Code Then
' Option 1: Strong typed access to DoubleAggregateSummary.
Dim summary1 As DoubleAggregateSummary = CType(group.GetSummary(summaryDescriptor), DoubleAggregateSummary)
summaryText = String.Format("{0:c}", summary1.Average)
' or Option 2: Use reflection to get "Average" property of summary
summaryText = String.Format("{0:c}", group.GetSummaryProperty(summaryDescriptor, "Average"))
' or Option 3: Use reflection to get "Average" property of summary and format it
summaryText = group.GetFormattedSummaryProperty(summaryDescriptor, "Average", "{0:c}")
Else
' This is the code you had to use in version 3.0 and earlier (still working but bit more complicate)
If Not (summaryDescriptor Is Nothing) Then
Dim indexOfSd1 As Integer = table.TableDescriptor.Summaries.IndexOf(summaryDescriptor)
' strong typed - you have to cast to DoubleAggregateSummary.
Dim summary1 As DoubleAggregateSummary = CType(group.GetSummaries(table)(indexOfSd1), DoubleAggregateSummary)
summaryText = String.Format("{0:c}", summary1.Average)
End If
End If
Return summaryText
End Function 'GetSummary
See Also
GetSummary(String)
Gets the value of the summary with the specified name.
Declaration
public ITreeTableSummary GetSummary(string summaryDescriptorName)
Parameters
Type | Name | Description |
---|---|---|
System.String | summaryDescriptorName | A summary in the TableDescriptor and Summaries collection. |
Returns
Type | Description |
---|---|
ITreeTableSummary | An object that implements the ITreeTableSummary. You should cast the object to the correct runtime type depending on the SummaryType, e.g. DoubleAggregateSummary in case of a SummaryType and DoubleAggregate |
GetSummaryProperty(SummaryDescriptor, String)
Gets the value of the specified summary.
Declaration
public object GetSummaryProperty(SummaryDescriptor sd, string propertyName)
Parameters
Type | Name | Description |
---|---|---|
SummaryDescriptor | sd | A summary of the TableDescriptor.Summaries collection. |
System.String | propertyName | The property in the summary. The value will be determined with reflection and converted to a string. |
Returns
Type | Description |
---|---|
System.Object | The specified property as string. |
Examples
string GetAverageSummary(SummaryDescriptor summaryDescriptor, Group group)
{
Table table = group.ParentTable;
TableDescriptor td = table.TableDescriptor;
string summaryText = "";
bool use31Code = true;
if (use31Code)
{
// Option 1: Strong typed access to DoubleAggregateSummary.
DoubleAggregateSummary summary1 = (DoubleAggregateSummary) group.GetSummary(summaryDescriptor);
summaryText = string.Format("{0:c}", summary1.Average);
// or Option 2: Use reflection to get "Average" property of summary
summaryText = string.Format("{0:c}", group.GetSummaryProperty(summaryDescriptor, "Average"));
// or Option 3: Use reflection to get "Average" property of summary and format it
summaryText = group.GetFormattedSummaryProperty(summaryDescriptor, "Average", "{0:c}");
}
else
{
// This is the code you had to use in version 3.0 and earlier (still working but bit more complicate)
if (summaryDescriptor != null)
{
int indexOfSd1 = table.TableDescriptor.Summaries.IndexOf(summaryDescriptor);
// strong typed - you have to cast to DoubleAggregateSummary.
DoubleAggregateSummary summary1 = (DoubleAggregateSummary) group.GetSummaries(table)[indexOfSd1];
summaryText = string.Format("{0:c}", summary1.Average);
}
}
return summaryText;
}
Function GetAverageSummary(ByVal summaryDescriptor As SummaryDescriptor, ByVal group As Group) As String
Dim table As Table = group.ParentTable
Dim td As TableDescriptor = table.TableDescriptor
Dim summaryText As String = ""
Dim use31Code As Boolean = True
If use31Code Then
' Option 1: Strong typed access to DoubleAggregateSummary.
Dim summary1 As DoubleAggregateSummary = CType(group.GetSummary(summaryDescriptor), DoubleAggregateSummary)
summaryText = String.Format("{0:c}", summary1.Average)
' or Option 2: Use reflection to get "Average" property of summary
summaryText = String.Format("{0:c}", group.GetSummaryProperty(summaryDescriptor, "Average"))
' or Option 3: Use reflection to get "Average" property of summary and format it
summaryText = group.GetFormattedSummaryProperty(summaryDescriptor, "Average", "{0:c}")
Else
' This is the code you had to use in version 3.0 and earlier (still working but bit more complicate)
If Not (summaryDescriptor Is Nothing) Then
Dim indexOfSd1 As Integer = table.TableDescriptor.Summaries.IndexOf(summaryDescriptor)
' strong typed - you have to cast to DoubleAggregateSummary.
Dim summary1 As DoubleAggregateSummary = CType(group.GetSummaries(table)(indexOfSd1), DoubleAggregateSummary)
summaryText = String.Format("{0:c}", summary1.Average)
End If
End If
Return summaryText
End Function 'GetSummary
See Also
GetSummaryProperty(String, String)
Gets the value of the summary with the specified name.
Declaration
public object GetSummaryProperty(string summaryDescriptorName, string propertyName)
Parameters
Type | Name | Description |
---|---|---|
System.String | summaryDescriptorName | A summary of the TableDescriptor.Summaries collection. |
System.String | propertyName | The property in the summary. The value will be determined with reflection and converted to a string. |
Returns
Type | Description |
---|---|
System.Object | The specified property. |
Examples
string GetAverageSummary(SummaryDescriptor summaryDescriptor, Group group)
{
Table table = group.ParentTable;
TableDescriptor td = table.TableDescriptor;
string summaryText = "";
bool use31Code = true;
if (use31Code)
{
// Option 1: Strong typed access to DoubleAggregateSummary.
DoubleAggregateSummary summary1 = (DoubleAggregateSummary) group.GetSummary(summaryDescriptor);
summaryText = string.Format("{0:c}", summary1.Average);
// or Option 2: Use reflection to get "Average" property of summary
summaryText = string.Format("{0:c}", group.GetSummaryProperty(summaryDescriptor, "Average"));
// or Option 3: Use reflection to get "Average" property of summary and format it
summaryText = group.GetFormattedSummaryProperty(summaryDescriptor, "Average", "{0:c}");
}
else
{
// This is the code you had to use in version 3.0 and earlier (still working but bit more complicate)
if (summaryDescriptor != null)
{
int indexOfSd1 = table.TableDescriptor.Summaries.IndexOf(summaryDescriptor);
// strong typed - you have to cast to DoubleAggregateSummary.
DoubleAggregateSummary summary1 = (DoubleAggregateSummary) group.GetSummaries(table)[indexOfSd1];
summaryText = string.Format("{0:c}", summary1.Average);
}
}
return summaryText;
}
Function GetAverageSummary(ByVal summaryDescriptor As SummaryDescriptor, ByVal group As Group) As String
Dim table As Table = group.ParentTable
Dim td As TableDescriptor = table.TableDescriptor
Dim summaryText As String = ""
Dim use31Code As Boolean = True
If use31Code Then
' Option 1: Strong typed access to DoubleAggregateSummary.
Dim summary1 As DoubleAggregateSummary = CType(group.GetSummary(summaryDescriptor), DoubleAggregateSummary)
summaryText = String.Format("{0:c}", summary1.Average)
' or Option 2: Use reflection to get "Average" property of summary
summaryText = String.Format("{0:c}", group.GetSummaryProperty(summaryDescriptor, "Average"))
' or Option 3: Use reflection to get "Average" property of summary and format it
summaryText = group.GetFormattedSummaryProperty(summaryDescriptor, "Average", "{0:c}")
Else
' This is the code you had to use in version 3.0 and earlier (still working but bit more complicate)
If Not (summaryDescriptor Is Nothing) Then
Dim indexOfSd1 As Integer = table.TableDescriptor.Summaries.IndexOf(summaryDescriptor)
' strong typed - you have to cast to DoubleAggregateSummary.
Dim summary1 As DoubleAggregateSummary = CType(group.GetSummaries(table)(indexOfSd1), DoubleAggregateSummary)
summaryText = String.Format("{0:c}", summary1.Average)
End If
End If
Return summaryText
End Function 'GetSummary
See Also
GetVisibleCount()
Overridden to get the number of visible elements.
Declaration
public override int GetVisibleCount()
Returns
Type | Description |
---|---|
System.Int32 | Visible element count. |
Overrides
GetVisibleCustomCount()
Overridden to get the custom count for visible elements.
Declaration
public override double GetVisibleCustomCount()
Returns
Type | Description |
---|---|
System.Double | Visible custom count. |
Overrides
GetYAmountCount()
Overridden to get the row height for the element.
Declaration
public override double GetYAmountCount()
Returns
Type | Description |
---|---|
System.Double | Returns element's row height. |
Overrides
InitializeDetails(Boolean, SortColumnDescriptorCollection, Boolean)
Initializes the sections for a new group.
Declaration
public void InitializeDetails(bool hasRecords, SortColumnDescriptorCollection sortColumns, bool isExpanded)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | hasRecords | Specifies if group will be filled with records or nested groups. |
SortColumnDescriptorCollection | sortColumns | The sortColumns that define the category of the group. |
System.Boolean | isExpanded | The initial expansion state for the group. |
InvalidateCounter()
Overridden to reset the counter fields for the given element.
Declaration
public override void InvalidateCounter()
Overrides
InvalidateCounterBottomUp()
Overridden to reset the counters for all groups from bottom to top.
Declaration
public override void InvalidateCounterBottomUp()
Overrides
InvalidateCounterTopDown(Boolean)
Overridden to reset the counter fields for all the elements from top to bottom.
Declaration
public override void InvalidateCounterTopDown(bool notifyCounterSource)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | notifyCounterSource | When true notifies the counter source. |
Overrides
InvalidateSummariesBottomUp()
Overridden to reset the summaries for all the elements from bottom to up.
Declaration
public override void InvalidateSummariesBottomUp()
Overrides
InvalidateSummariesTopDown()
Overridden to reset the summary fields for all the elements from top to bottom.
Declaration
public override void InvalidateSummariesTopDown()
Overrides
InvalidateSummary()
Overridden to reset the summaries for the given element.
Declaration
public override void InvalidateSummary()
Overrides
IsChildVisible(Element)
Overridden to determine whether the child elements are visible or not.
Declaration
public override bool IsChildVisible(Element el)
Parameters
Type | Name | Description |
---|---|---|
Element | el | The Element. |
Returns
Type | Description |
---|---|
System.Boolean | True if the child is visible; Otherwise False. |
Overrides
IsGroupVisible()
Determines whether the group should be visible or not. By default a group is hidden if it does not have any records that meet filter criteria.
Declaration
protected virtual bool IsGroupVisible()
Returns
Type | Description |
---|---|
System.Boolean | True if group should be visible; Otherwise False. |
OnInitializeSections(Boolean, SortColumnDescriptorCollection)
Called from InitializeDetails(Boolean, SortColumnDescriptorCollection, Boolean) to initialize the sections for a new group. Override this method if you want to customize the sections that are available for a group.
Declaration
protected virtual void OnInitializeSections(bool hasRecords, SortColumnDescriptorCollection sortColumns)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | hasRecords | Specifies if group will be filled with records or nested groups. |
SortColumnDescriptorCollection | sortColumns | The sortColumns that define the category of the group. |
Examples
protected override void OnInitializeSections(bool hasRecords, SortColumnDescriptorCollection sortColumns)
{
this.Sections.Add(this.ParentTableDescriptor.CreateCaptionSection(this));
if (this.IsTopLevelGroup)
this.Sections.Add(this.ParentTableDescriptor.CreateAddNewRecordSection(this));
if (hasRecords)
this.Sections.Add(this.ParentTableDescriptor.CreateRecordsDetails(this, sortColumns));
else
this.Sections.Add(this.ParentTableDescriptor.CreateGroupsDetails(this, sortColumns));
this.Sections.Add(this.ParentTableDescriptor.CreateSummarySection(this));
}
OnInitializeVisibleCounters()
Initializes the visible count.
Declaration
protected virtual void OnInitializeVisibleCounters()
SetChildListPosition(Int32)
Specifies the position of the first unsorted record in this list in the UnsortedRecords collection.
Declaration
public void SetChildListPosition(int index)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | The Index. |
Remarks
The ChildTable must belong to a UniformChildList relation.
SetExpanded(Boolean, Boolean, Boolean)
Sets the group's expansion state and optionally invalidates counters and optionally raises DisplayElementChanging and DisplayElementChanged events.
Declaration
public void SetExpanded(bool value, bool refreshCounters, bool raiseDisplayElementChangeEvents)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | value | The new expansion state. |
System.Boolean | refreshCounters | True if counters should be invalidated; OtherwiseFalse. |
System.Boolean | raiseDisplayElementChangeEvents | True if DisplayElementChanging and DisplayElementChanged events should be raised; Otherwise False. |
ShouldShowCaption()
Gets a value indicating whether the caption should be visible in DisplayElements or not.
Declaration
public virtual bool ShouldShowCaption()
Returns
Type | Description |
---|---|
System.Boolean | Returns True. |
SupportsId()
Overridden to specify whether this object can be uniquely identified with the id or not.
Declaration
public override bool SupportsId()
Returns
Type | Description |
---|---|
System.Boolean | Returns True. |
Overrides
ToString()
Overridden to get string representation of the object.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
System.String | String representation of the current object. |
Overrides
UniqueGroupIdsToString()
Gets a string combined of all group categories which is used by FilterBarCells to name the RecordFilterDescriptor specific for a group.
Declaration
public string UniqueGroupIdsToString()
Returns
Type | Description |
---|---|
System.String | A string combining all group categories. |