Grouping & totals
GridControlGroup rows by a column, with averages and counts in the group captions and footers.
Overview
GroupColumns opens the grid already grouped; with AllowGrouping the user regroups by dragging a header
into the bar above the grid. AggregateRows lists what to compute per group: each AggregateColumn names a
field, an AggregateType and a format, and its GroupCaptionTemplate and GroupFooterTemplate
decide where the value is printed and how. ShowSearchBar adds a search box to the grid toolbar.
Examples
#Item catalog grouped by category
A cost-item catalog: material, labor, subcontract, equipment and overhead lines keyed by phase, each with a default cost and an Active flag. It opens grouped by Category; drag Phase into the bar to regroup. Each caption shows the average default cost and the item count; each footer repeats the average. Sort Default $ descending for the priciest items, filter Active for the inactive ones, or type in the search box.
| Category | Item ID | Description | Phase | UOM | Default $ | Active |
|---|---|---|---|---|---|---|
| E (Equipment)avg $283.63(13 items) | ||||||
| ITM-1004 | Permits component 4 | 010 Permits | SY | $507.04 | True | |
| ITM-1008 | Excavation component 3 | 030 Excavation | SY | $188.52 | False | |
| ITM-1012 | Foundation component 2 | 050 Foundation | SY | $468.83 | True | |
| ITM-1014 | Framing component 1 | 070 Framing | SY | $518.22 | True | |
| ITM-1026 | Plumbing Rough component 4 | 120 Plumbing Rough | LF | $246.40 | True | |
| ITM-1031 | Electrical Rough component 3 | 150 Electrical Rough | LF | $152.53 | False | |
| ITM-1036 | HVAC component 2 | 180 HVAC | LF | $431.48 | True | |
| ITM-1038 | Insulation component 1 | 210 Insulation | LF | $124.03 | True | |
| ITM-1046 | Drywall component 5 | 240 Drywall | HR | $100.63 | True | |
| ITM-1050 | Cabinets component 4 | 270 Cabinets | HR | $315.68 | True | |
| ITM-1054 | Flooring component 3 | 300 Flooring | HR | $227.35 | True | |
| ITM-1058 | Paint component 2 | 330 Paint | HR | $77.09 | True | |
| ITM-1063 | Finishes component 1 | 360 Finishes | HR | $329.38 | True | |
| L (Labor)avg $239.60(13 items) | ||||||
| ITM-1002 | Permits component 2 | 010 Permits | LF | $191.46 | False | |
| ITM-1006 | Excavation component 1 | 030 Excavation | LF | $309.76 | True | |
| ITM-1017 | Framing component 4 | 070 Framing | HR | $424.47 | True | |
| ITM-1021 | Roofing component 3 | 090 Roofing | HR | $146.54 | True | |
| ITM-1024 | Plumbing Rough component 2 | 120 Plumbing Rough | HR | $58.84 | True | |
| ITM-1029 | Electrical Rough component 1 | 150 Electrical Rough | HR | $42.54 | False | |
| ITM-1034 | Electrical Rough component 6 | 150 Electrical Rough | CY | $370.10 | True | |
| ITM-1041 | Insulation component 4 | 210 Insulation | CY | $375.84 | True | |
| ITM-1044 | Drywall component 3 | 240 Drywall | CY | $275.60 | True | |
| ITM-1048 | Cabinets component 2 | 270 Cabinets | CY | $441.93 | False | |
| ITM-1052 | Flooring component 1 | 300 Flooring | CY | $55.03 | True | |
| ITM-1061 | Paint component 5 | 330 Paint | SF | $46.79 | True | |
| ITM-1066 | Finishes component 4 | 360 Finishes | SF | $375.95 | True | |
| M (Material)avg $306.17(13 items) | ||||||
| ITM-1001 | Permits component 1 | 010 Permits | Each | $340.88 | True | |
| ITM-1010 | Excavation component 5 | 030 Excavation | LS | $297.11 | False | |
| ITM-1016 | Framing component 3 | 070 Framing | LS | $116.01 | True | |
| ITM-1020 | Roofing component 2 | 090 Roofing | LS | $397.29 | True | |
| ITM-1023 | Plumbing Rough component 1 | 120 Plumbing Rough | LS | $485.20 | True | |
| ITM-1028 | Plumbing Rough component 6 | 120 Plumbing Rough | SY | $429.30 | True | |
| ITM-1033 | Electrical Rough component 5 | 150 Electrical Rough | SY | $68.27 | True | |
| ITM-1040 | Insulation component 3 | 210 Insulation | SY | $219.18 | True | |
| ITM-1043 | Drywall component 2 | 240 Drywall | SY | $290.15 | True | |
| ITM-1047 | Cabinets component 1 | 270 Cabinets | SY | $355.71 | True | |
| ITM-1056 | Flooring component 5 | 300 Flooring | LF | $394.25 | True | |
| ITM-1060 | Paint component 4 | 330 Paint | LF | $504.39 | True | |
| ITM-1065 | Finishes component 3 | 360 Finishes | LF | $82.51 | True | |
| O (Overhead)avg $242.38(14 items) | ||||||
| ITM-1005 | Permits component 5 | 010 Permits | CY | $58.73 | True | |
| ITM-1009 | Excavation component 4 | 030 Excavation | CY | $39.55 | True | |
| ITM-1013 | Foundation component 3 | 050 Foundation | CY | $396.26 | True | |
| ITM-1015 | Framing component 2 | 070 Framing | CY | $287.39 | True | |
| ITM-1019 | Roofing component 1 | 090 Roofing | CY | $188.84 | True | |
| ITM-1027 | Plumbing Rough component 5 | 120 Plumbing Rough | SF | $204.45 | True | |
| ITM-1032 | Electrical Rough component 4 | 150 Electrical Rough | SF | $402.71 | True | |
| ITM-1037 | HVAC component 3 | 180 HVAC | SF | $88.81 | True | |
| ITM-1039 | Insulation component 2 | 210 Insulation | SF | $229.30 | True | |
| ITM-1042 | Drywall component 1 | 240 Drywall | SF | $465.79 | True | |
| ITM-1051 | Cabinets component 5 | 270 Cabinets | Each | $524.21 | True | |
| ITM-1055 | Flooring component 4 | 300 Flooring | Each | $115.92 | True | |
| ITM-1059 | Paint component 3 | 330 Paint | Each | $208.07 | True | |
| ITM-1064 | Finishes component 2 | 360 Finishes | Each | $183.35 | True | |
| S (Subcontract)avg $320.88(14 items) | ||||||
| ITM-1003 | Permits component 3 | 010 Permits | SF | $484.78 | True | |
| ITM-1007 | Excavation component 2 | 030 Excavation | SF | $65.89 | True | |
| ITM-1011 | Foundation component 1 | 050 Foundation | SF | $312.06 | True | |
| ITM-1018 | Framing component 5 | 070 Framing | Each | $309.71 | True | |
| ITM-1022 | Roofing component 4 | 090 Roofing | Each | $355.43 | True | |
| ITM-1025 | Plumbing Rough component 3 | 120 Plumbing Rough | Each | $423.95 | True | |
| ITM-1030 | Electrical Rough component 2 | 150 Electrical Rough | Each | $520.89 | False | |
| ITM-1035 | HVAC component 1 | 180 HVAC | Each | $265.28 | True | |
| ITM-1045 | Drywall component 4 | 240 Drywall | LS | $356.77 | True | |
| ITM-1049 | Cabinets component 3 | 270 Cabinets | LS | $213.74 | True | |
| ITM-1053 | Flooring component 2 | 300 Flooring | LS | $356.28 | True | |
| ITM-1057 | Paint component 1 | 330 Paint | LS | $441.01 | True | |
| ITM-1062 | Paint component 6 | 330 Paint | SY | $336.32 | True | |
| ITM-1067 | Finishes component 5 | 360 Finishes | SY | $50.20 | True | |
Documentation
GridControl grouping parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
AllowGrouping | bool | false | Required for any grouping. Shows the group bar, lets a header be dragged onto it and a chip be removed, and makes GroupColumns take effect; off, the grid stays flat. |
GroupColumns | List<string>? | null | Fields to group by on first render, outermost first. A new list instance re-syncs the groups. |
HideGroupedColumns | bool | true | Hides a grouped column from the data rows. False keeps it in place as well. |
ShowGroupCount | bool | false | Appends (n items) to each caption. |
DefaultGroupsCollapsed | bool | false | Start with every group collapsed. |
ShowGroupExpandCollapse | bool | true | Shows the Expand All / Collapse All toggle in the group bar. |
GroupExpandIconStyle | GroupExpandIconStyle | GroupExpandIconStyle.PlusMinus | PlusMinus boxes or Triangle chevrons on the caption rows. The expand-icon template and glyph parameters override the preset. |
GroupHeaderTextSelector | Func<string, string, IReadOnlyList<TValue>, string>? | null | Replaces the caption text. Receives the field, the key as text and the group's rows; the key itself, and so collapse state, is unchanged. |
AggregateRows | List<AggregateRow>? | null | What to compute and where to print it; the two tables below. |
GroupedColumnColor / GroupItemTextColor / GroupTotalTextColor | string | "" | Optional CSS colours for the grouped values in caption rows and chips, the caption text, and the aggregate values. Empty inherits. |
ShowRowCountInFooter | bool | false | Prints the row count of the complete filtered result in the footer, not of the rendered window or page. |
EnableGroupedRowWindowing | bool | true | Windows the rows of a grouped grid the way a flat grid is windowed. Off renders every row. |
GroupFooterTemplate | RenderFragment<object>? | null | Declared, but GridControl never reads it. |
GroupFootersAlwaysVisible | bool | false | Declared, but GridControl never reads it. |
GridColumn
| Parameter | Type | Default | Description |
|---|---|---|---|
AllowGrouping | bool | true | False keeps this column out of grouping: its header cannot be dropped on the bar, its header menu offers no group command, and GroupByColumnAsync ignores it. |
AggregateRow
| Property | Type | Default | Description |
|---|---|---|---|
Columns | List<AggregateColumn> | new() | The aggregates of this row. |
ShowInGroupFooter | bool | true | A row of values under each group, aligned with the columns. |
ShowInFooter | bool | false | The same row after all data. |
ShowInGroupCaption | bool | false | Every value inline in the caption, after the group name and the count. |
ShowInGroupHeader | bool | false | An extra aligned row at the top of each group, under the caption. |
AggregateColumn
| Property | Type | Default | Description |
|---|---|---|---|
Field | string | "" | The property to aggregate. |
Type | AggregateType | AggregateType.Sum | Sum, Average, Count, Min or Max. |
Format | string? | null | .NET format applied to the number, such as C2 or N0. |
FooterTemplate | string | "{value}" | Text with {value} for the number, used wherever no more specific template is set. The words Total:, Sub Total: and Grand Total: are removed from the result. |
GroupFooterTemplate | string? | null | Template for group footers; falls back to FooterTemplate. |
GroupCaptionTemplate | string? | null | Template for captions and the group header row; falls back to FooterTemplate. |
GridControlEvents, grouping
| Event | Payload | Description |
|---|---|---|
Grouping | GroupEventArgs | Before a field is grouped by drag or GroupByColumnAsync; Field names it and Cancel refuses. Not raised for GroupColumns. |
Grouped | GroupEventArgs | After the group is added. |
Ungrouping | GroupEventArgs | Before a field is ungrouped from its chip, the bar's Clear All or UngroupColumnAsync; Cancel refuses. ClearGroupingAsync raises neither this nor Ungrouped. |
Ungrouped | GroupEventArgs | After the group is removed. |
Grouping methods
| Method | Inputs | Returns | Description |
|---|---|---|---|
GroupByColumnAsync() | string field | Task | Adds a group, with the events and the column's AllowGrouping honoured. |
UngroupColumnAsync() | string field | Task | Removes a group, with the events. |
ClearGroupingAsync() | — | Task | Removes every group without raising the events. |
ExpandAllGroupAsync() | — | Task | Expands every group and re-renders. |
CollapseAllGroupAsync() | — | Task | Marks every group collapsed; the change shows on the next render. |
AggregateType is Sum, Average, Count, Min or Max. Values are
read as doubles: numeric properties directly, anything else through a parse of its text. Count therefore counts the
values that parse as numbers, so on a text or boolean column it prints nothing; count a numeric column instead, as this page does.
A group footer and the grid footer print one value per column, the first AggregateColumn for that field; a caption
prints every value of every caption row.