Grouping & totals

GridControl

Group 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.

Example
Razor
C#
Category ×
CategoryItem ID Description Phase UOM Default $ Active
−E (Equipment)avg $283.63(13 items)
ITM-1004Permits component 4010 PermitsSY$507.04True
ITM-1008Excavation component 3030 ExcavationSY$188.52False
ITM-1012Foundation component 2050 FoundationSY$468.83True
ITM-1014Framing component 1070 FramingSY$518.22True
ITM-1026Plumbing Rough component 4120 Plumbing RoughLF$246.40True
ITM-1031Electrical Rough component 3150 Electrical RoughLF$152.53False
ITM-1036HVAC component 2180 HVACLF$431.48True
ITM-1038Insulation component 1210 InsulationLF$124.03True
ITM-1046Drywall component 5240 DrywallHR$100.63True
ITM-1050Cabinets component 4270 CabinetsHR$315.68True
ITM-1054Flooring component 3300 FlooringHR$227.35True
ITM-1058Paint component 2330 PaintHR$77.09True
ITM-1063Finishes component 1360 FinishesHR$329.38True
−L (Labor)avg $239.60(13 items)
ITM-1002Permits component 2010 PermitsLF$191.46False
ITM-1006Excavation component 1030 ExcavationLF$309.76True
ITM-1017Framing component 4070 FramingHR$424.47True
ITM-1021Roofing component 3090 RoofingHR$146.54True
ITM-1024Plumbing Rough component 2120 Plumbing RoughHR$58.84True
ITM-1029Electrical Rough component 1150 Electrical RoughHR$42.54False
ITM-1034Electrical Rough component 6150 Electrical RoughCY$370.10True
ITM-1041Insulation component 4210 InsulationCY$375.84True
ITM-1044Drywall component 3240 DrywallCY$275.60True
ITM-1048Cabinets component 2270 CabinetsCY$441.93False
ITM-1052Flooring component 1300 FlooringCY$55.03True
ITM-1061Paint component 5330 PaintSF$46.79True
ITM-1066Finishes component 4360 FinishesSF$375.95True
−M (Material)avg $306.17(13 items)
ITM-1001Permits component 1010 PermitsEach$340.88True
ITM-1010Excavation component 5030 ExcavationLS$297.11False
ITM-1016Framing component 3070 FramingLS$116.01True
ITM-1020Roofing component 2090 RoofingLS$397.29True
ITM-1023Plumbing Rough component 1120 Plumbing RoughLS$485.20True
ITM-1028Plumbing Rough component 6120 Plumbing RoughSY$429.30True
ITM-1033Electrical Rough component 5150 Electrical RoughSY$68.27True
ITM-1040Insulation component 3210 InsulationSY$219.18True
ITM-1043Drywall component 2240 DrywallSY$290.15True
ITM-1047Cabinets component 1270 CabinetsSY$355.71True
ITM-1056Flooring component 5300 FlooringLF$394.25True
ITM-1060Paint component 4330 PaintLF$504.39True
ITM-1065Finishes component 3360 FinishesLF$82.51True
−O (Overhead)avg $242.38(14 items)
ITM-1005Permits component 5010 PermitsCY$58.73True
ITM-1009Excavation component 4030 ExcavationCY$39.55True
ITM-1013Foundation component 3050 FoundationCY$396.26True
ITM-1015Framing component 2070 FramingCY$287.39True
ITM-1019Roofing component 1090 RoofingCY$188.84True
ITM-1027Plumbing Rough component 5120 Plumbing RoughSF$204.45True
ITM-1032Electrical Rough component 4150 Electrical RoughSF$402.71True
ITM-1037HVAC component 3180 HVACSF$88.81True
ITM-1039Insulation component 2210 InsulationSF$229.30True
ITM-1042Drywall component 1240 DrywallSF$465.79True
ITM-1051Cabinets component 5270 CabinetsEach$524.21True
ITM-1055Flooring component 4300 FlooringEach$115.92True
ITM-1059Paint component 3330 PaintEach$208.07True
ITM-1064Finishes component 2360 FinishesEach$183.35True
−S (Subcontract)avg $320.88(14 items)
ITM-1003Permits component 3010 PermitsSF$484.78True
ITM-1007Excavation component 2030 ExcavationSF$65.89True
ITM-1011Foundation component 1050 FoundationSF$312.06True
ITM-1018Framing component 5070 FramingEach$309.71True
ITM-1022Roofing component 4090 RoofingEach$355.43True
ITM-1025Plumbing Rough component 3120 Plumbing RoughEach$423.95True
ITM-1030Electrical Rough component 2150 Electrical RoughEach$520.89False
ITM-1035HVAC component 1180 HVACEach$265.28True
ITM-1045Drywall component 4240 DrywallLS$356.77True
ITM-1049Cabinets component 3270 CabinetsLS$213.74True
ITM-1053Flooring component 2300 FlooringLS$356.28True
ITM-1057Paint component 1330 PaintLS$441.01True
ITM-1062Paint component 6330 PaintSY$336.32True
ITM-1067Finishes component 5360 FinishesSY$50.20True

Documentation

GridControl grouping parameters

ParameterTypeDefaultDescription
AllowGroupingboolfalseRequired 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.
GroupColumnsList<string>?nullFields to group by on first render, outermost first. A new list instance re-syncs the groups.
HideGroupedColumnsbooltrueHides a grouped column from the data rows. False keeps it in place as well.
ShowGroupCountboolfalseAppends (n items) to each caption.
DefaultGroupsCollapsedboolfalseStart with every group collapsed.
ShowGroupExpandCollapsebooltrueShows the Expand All / Collapse All toggle in the group bar.
GroupExpandIconStyleGroupExpandIconStyleGroupExpandIconStyle.PlusMinusPlusMinus boxes or Triangle chevrons on the caption rows. The expand-icon template and glyph parameters override the preset.
GroupHeaderTextSelectorFunc<string, string, IReadOnlyList<TValue>, string>?nullReplaces the caption text. Receives the field, the key as text and the group's rows; the key itself, and so collapse state, is unchanged.
AggregateRowsList<AggregateRow>?nullWhat to compute and where to print it; the two tables below.
GroupedColumnColor / GroupItemTextColor / GroupTotalTextColorstring""Optional CSS colours for the grouped values in caption rows and chips, the caption text, and the aggregate values. Empty inherits.
ShowRowCountInFooterboolfalsePrints the row count of the complete filtered result in the footer, not of the rendered window or page.
EnableGroupedRowWindowingbooltrueWindows the rows of a grouped grid the way a flat grid is windowed. Off renders every row.
GroupFooterTemplateRenderFragment<object>?nullDeclared, but GridControl never reads it.
GroupFootersAlwaysVisibleboolfalseDeclared, but GridControl never reads it.

GridColumn

ParameterTypeDefaultDescription
AllowGroupingbooltrueFalse 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

PropertyTypeDefaultDescription
ColumnsList<AggregateColumn>new()The aggregates of this row.
ShowInGroupFooterbooltrueA row of values under each group, aligned with the columns.
ShowInFooterboolfalseThe same row after all data.
ShowInGroupCaptionboolfalseEvery value inline in the caption, after the group name and the count.
ShowInGroupHeaderboolfalseAn extra aligned row at the top of each group, under the caption.

AggregateColumn

PropertyTypeDefaultDescription
Fieldstring""The property to aggregate.
TypeAggregateTypeAggregateType.SumSum, Average, Count, Min or Max.
Formatstring?null.NET format applied to the number, such as C2 or N0.
FooterTemplatestring"{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.
GroupFooterTemplatestring?nullTemplate for group footers; falls back to FooterTemplate.
GroupCaptionTemplatestring?nullTemplate for captions and the group header row; falls back to FooterTemplate.

GridControlEvents, grouping

EventPayloadDescription
GroupingGroupEventArgsBefore a field is grouped by drag or GroupByColumnAsync; Field names it and Cancel refuses. Not raised for GroupColumns.
GroupedGroupEventArgsAfter the group is added.
UngroupingGroupEventArgsBefore a field is ungrouped from its chip, the bar's Clear All or UngroupColumnAsync; Cancel refuses. ClearGroupingAsync raises neither this nor Ungrouped.
UngroupedGroupEventArgsAfter the group is removed.

Grouping methods

MethodInputsReturnsDescription
GroupByColumnAsync()string fieldTaskAdds a group, with the events and the column's AllowGrouping honoured.
UngroupColumnAsync()string fieldTaskRemoves a group, with the events.
ClearGroupingAsync()—TaskRemoves every group without raising the events.
ExpandAllGroupAsync()—TaskExpands every group and re-renders.
CollapseAllGroupAsync()—TaskMarks 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.

An unhandled error has occurred. Reload 🗙

Rejoining the server...

Rejoin failed... trying again in seconds.

Failed to rejoin.
Please retry or reload the page.

The session has been paused by the server.

Failed to resume the session.
Please retry or reload the page.