GridColumn / GridColumns

By default, MainGrid and SubGrid render whatever column set the active Dataverse view returns. The GridColumn component lets you take explicit control: when one or more GridColumn children are declared, the grid renders only those columns, in the declared order, and the server-side projection is rewritten to fetch exactly the declared set. Use this to slim a grid down to the columns that matter for a specific page, reorder them, customise width / alignment, supply per-cell templates, or surface columns that aren't in the underlying view — without editing the Dataverse view itself.

Live Demo

A MainGrid over the contact table mixing a GridTemplateColumn with three regular GridColumn children. The first cell is synthetic — composes an initials avatar plus a bold name from raw firstname + lastname values pulled into the projection via DependsOn. The remaining three demonstrate per-cell ChildContent templates on bound columns: a mailto: link, a phone number with an inline icon, and a colour-coded age badge that reads the raw IntValue via GetValueOrDefault<T>() for the threshold comparison. Click the gear icon and flip Editable on to see the template column's EditChildContent in action — the Full Name cell swaps from the avatar render to two side-by-side TextEdit editors bound to firstname + lastname.

React example Blazor example React TypeScript Razor
Anyone can view contacts in the grid below. Log in to create, view, and update your own contacts.
All Contacts
Sort Editable
All Contacts
Page size 102050100
Sort Editable
Full Name
Full Name
Email
Email
Type the primary email address for the contact.
Phone
Phone
Type the mobile phone number for the contact.
Age
Age
Birthday
Birthday
Enter the contact's birthday for use in customer gift programs or other communications.

Basic Usage

Drop GridColumn components inside a GridColumns wrapper under the grid. Declared column names override the FetchXML's <attribute> projection — the server fetches the declared columns even if they aren't in the active view's column selection. The TableName parameter is optional in declared mode: when omitted, the grid's own TableName is used (no need to repeat it on every column).

React Blazor

Replace, not additive

Declaring any GridColumn children switches the grid into replace mode: declared columns are the entire rendered column set AND the entire fetched column set. View columns not declared here are dropped from both the render and the server's projection. If you want most view columns with a tweak or two, drop the wrapper entirely or build a custom view via CustomViewDefinitions.

Required Parameters

Each GridColumn declaration takes:

  • ColumnName — Required. Logical name of the column to project. Supports dot-notation for aliased linked-entity columns (primarycontactid.emailaddress1); the alias must already exist as a <link-entity> in the active view's FetchXML.
  • TableName — Optional. Logical name of the table whose metadata describes this column. When omitted, falls back to the grid's TableName — handy for keeping consumer markup terse on single-table grids.

Column Width

Use Width to override the view's stored width. Accepts any CSS length — pixels ("150px"), percentages ("20%"), or "auto". Without an explicit width, the grid falls back to the metadata-derived default and the table's natural distribution.

React Blazor

Alignment

Use Align to override horizontal alignment for both the header and body cells. Numeric and money columns default to Align.End (right-aligned) via the metadata-driven fallback; boolean columns default to Align.Center. Set it explicitly when you want a non-default alignment, or to align a custom-templated cell consistently.

React Blazor

Linked-Entity Columns

Aliased linked-entity columns use dot-notation matching how the view's FetchXML aliases them. The alias must already be defined as a <link-entity> in the active view. Set TableName to the source table the alias points to so metadata resolution lands on the right entity. The server returns these columns with their parent-table-qualified localized display name (e.g. "Email (Primary Contact)") — no client-side humanisation required.

React Blazor

A GridRelatedRecordsColumn lists, for each row, the records related to it through a one-to-many or many-to-many relationship — the regions an account is linked to, the contacts that belong to it. By default the cell shows their primary names, sorted alphabetically and separated by commas. Each name can link to its record, and a cell can show more than names: ask for further columns of the related table and render each record yourself, as a card or a badge, or render the whole cell. The grid's search box searches the column too, matching a row by its related records and only ever by ones the user may read.

Related records demo

Accounts with two columns over their contacts: the contacts' names, each a link to the contact, and each contact's email address as a badge.

React example Blazor example React TypeScript Razor
Anyone can view the demo accounts and their contacts in the grid below. Log in to see the accounts and contacts you created listed too.
All Accounts
Export to Excel Export to Excel Export to CSV
Sort
All Accounts
Export to Excel Export to Excel Export to CSV
Page size 102050100
Sort
Account Name
Account Name
Type the company or business name.
Contacts
Contacts
Contact emails
Contact emails
Abernathy - MacGyverBradford Kiehn, Jaydon Baumbach, Karlee Kuphal, Keshawn Lubowitz, Salma Yost
Abshire - MarksAiyana Upton, Archibald Bailey, Carolyne Moen, Trey Toy
Adams - TorphyAmelie King, Cordelia Wiegand, Elisabeth Boehm, Krystel Torp, Maximillian Kertzmann, Merle Vandervort
Altenwerth, D'Amore and ManteChaim Rodriguez, Hayley Stamm, Heidi Reichel, Leonel Cormier, Marcelle Blanda, Roy Buckridge
Ankunding and SonsFatima White, Lurline Williamson, Violette Conn
Balistreri, Heller and MurphyAisha Collins, Angie Kreiger, Henderson Ryan, Hilbert Hahn, Lexie Douglas, Mozelle Lebsack
Balistreri, Steuber and SchultzDelmer Howell, Gussie Waters, Jake Bogisich, Jameson Sipes, Sydnee Koch
Bartoletti LLCCecil Sipes, Joshuah Barrows, Liana Zieme, Magdalena Russel, Matilde Abshire
Bartoletti, Ratke and BeattyCecilia Hammes, Herbert Wiegand, Tabitha Morissette
Barton, Koepp and CroninBeaulah Collins, Boris Price, Marc Dibbert, Reva Koss
React Blazor

How related records are loaded

The related records are loaded for the whole page at once, after the page itself: one query per column, however many rows the page holds. They're read as the current user, through the related table's own permissions, so a row lists only the related records the user could read on their own. The column can't be sorted.

Self-referencing relationships

When a many-to-many relationship relates a table to itself, say which side the grid's rows are on: Referencing for the relationship's first table, Referenced for its second.

React Blazor

Grids bound to a data source

A grid bound to a ViewDataSource (Blazor) or useViewDataSource (React) shows the rows the data source loaded, so name the same relationship in the data source's RelatedRecords / relatedRecords option as well.

Per-Cell Templates

Supply ChildContent to render each cell with custom markup. The template receives GridRowContext — its PrimaryRecord property exposes the row's full TableRecord (typed column values, formatted values, permissions, all of it). Useful for conditional formatting (red text over a threshold), icons, badges, links, or anything else you can build from the row's record.

React Blazor

Knowing the Cell: CellTemplate

ChildContent receives the row, which every cell in it shares, so it can't tell which column it is rendering — or what the grid's search matched in it. When the cell needs to know, supply CellTemplate instead. It receives a GridColumnCellContext: the Row, the cell's ColumnName, Metadata and typed Value, the DisplayValue the built-in cell would show, and Highlight(text), which marks what the search matched exactly as the built-in cells do — the search term in text, lookup and choice columns, and the whole value of a number or date column whose comparison holds. It takes precedence over ChildContent when both are set. In React a cellRenderer already receives the cell's value, metadata and searchText: pass searchText to <Highlighter> for text, and for a number or money column check it with parseNumericSearch and matchesNumericSearch, and for a date column with parseDateSearch and matchesDateSearch — which takes the cell's formatted text rather than its value, since the day a date falls on depends on the time zone it's shown in, and the locale from useLocale() — marking the value with <HighlightFull> when they match.

React Blazor

Parent Record in SubGrids

When the grid is mounted as a SubGrid, GridRowContext.ParentRecord exposes the surrounding RecordContext's record (the SubGrid's parent). Reach for it inside a ChildContent template when conditional formatting needs to compare a row's column against the parent's — e.g. highlight contacts whose industrycode doesn't match the parent account's, or label rows owned by the parent's owner. null on a standalone MainGrid where there's no parent record.

React Blazor

React parity

The React side surfaces the same surface as cellRenderer's parentRecord prop (CellRendererProps.parentRecord).

GridTemplateColumn

Use GridTemplateColumn when a column doesn't map to a single Dataverse column — combine multiple raw values into one cell, render a status badge keyed on several fields, or emit a pure-decoration actions cell with no data dependency at all. Unlike GridColumn, a template column has no ColumnName: declare the columns the renderer reads via DependsOn and the framework merges them into the FetchXML projection, so the data lands in ctx.Row.PrimaryRecord when your template runs. The ChildContent receives a GridTemplateColumnContext (use the Context="ctx" attribute to name it) that carries the row, the optional SubGrid parent, and a pre-built DependsOnMetadata lookup keyed by the column names you declared.

React Blazor

A template column isn't part of the grid's search unless you say what to search it by. SearchBy (searchBy in React) names the columns: they're fetched automatically, matched by the grid's usual rules for their type (text starts with the search, or contains it after a leading *; a number or date column is compared), and listed in the search box under the template column's title. The columns in DependsOn are only fetched, never searched — a status code behind a badge shouldn't match what someone types. To mark what the search matched the way the built-in cells do, render the cell's text through ctx.Highlight(text) in Blazor, or pass the renderer's searchText to <Highlighter> in React; both are empty for a column without SearchBy.

Template column vs. GridColumn ChildContent

GridColumn ChildContent still customises a bound column — sorting, edit dispatch, and the column header all key off its single ColumnName. Reach for GridTemplateColumn only when there's no single underlying column to bind to (composite cells, decorative action cells, status badges combining multiple fields). Mixing the two is fine — they interleave in declared order across the grid's column set.

Decorative columns (no data dependency)

Skip DependsOn entirely when the cell renders pure-decoration content like inline buttons or icons. The framework still mounts the column at the right position in the rendered table; nothing is added to the server projection for that column.

React Blazor

Inline-Edit Templates

Pair a GridTemplateColumn's read-mode ChildContent with an EditChildContent to make the column editable when the grid's Editable toggle is on. The edit template receives a GridTemplateColumnEditContext — same row context as the read template (editCtx.Row.PrimaryRecord, the optional editCtx.Row.ParentRecord in a SubGrid, the editCtx.DependsOnMetadata lookup) plus an imperative editCtx.SetValue(columnName, value) helper.

EditChildContent fires when the grid is editable (AllowEdit="true" on the grid plus the user has flipped the Editable switch in the toolbar gear menu), the row isn't pending-delete, and the column itself declares an edit template. Decorative template columns that omit EditChildContent stay read-only even in edit mode — useful for actions columns that should always render the same buttons.

Pattern 1 — Drop-in standard editors

The most common case: the cell composes from multiple bound columns, and you want to let the user edit each one. Drop the matching <TextEdit> / <NumberEdit> / <ColumnEdit> editors inside EditChildContent — the framework cascades the row's primary record and matching EditContextValidator into that scope, so the editors self-register for dirty-tracking and validation exactly like they do under a bound <GridColumn>'s ChildContent. No extra wiring required.

React Blazor

Pattern 2 — Custom widget with SetValue

When the editor surface doesn't map 1:1 to a Dataverse column — a single "First Last" text box that parses into two columns, a slider tied to multiple percent fields, a custom date-range picker writing start + end — render your own input and call editCtx.SetValue(columnName, value) for each affected column. The framework routes the write to the correct AliasedTableRecord (handling dot-notation link-entity column names) and fires the record's ValueChanged event so dirty-tracking and the row's pending-update queue pick the change up.

React Blazor

Validation on the imperative path

Standard editors dropped into EditChildContent register with the row's EditContextValidator automatically and participate in the framework's validate-before-save gate. The editCtx.SetValue path bypasses that pipeline — the framework can't validate values that didn't come from a registered editor. If your custom widget needs to enforce constraints, run them inside the ValueChanged callback before calling SetValue, or fall back to the drop-in editor pattern when possible.

In a SubGrid

Everything that applies to MainGrid works identically on SubGrid. Pair declared columns with toolbar buttons in the Buttons render fragment for a focused inline-edit experience scoped to the parent record's related collection — and combine with @@context.ParentRecord in cell templates for conditional formatting that keys off the SubGrid's parent.

React Blazor

Totals

Give a column Aggregates and the grid adds a totals row under its columns, with each figure under the column it's for: Sum, Average, Minimum, Maximum or Count, several at once if you like, each with a format of its own if it needs one. The figures are worked out over every record the grid matches — its view, filters and search — not just the page on screen, so they change with a search and stay put as you page, sort or scroll. Number and money columns take every figure, date columns the earliest, latest and count, and any other column a count of the records that have a value in it. With the cards layout, the figures are listed after the cards, under each column's title.

React Blazor

For a grid that shows a view's columns rather than declaring its own, name the columns in the grid's ColumnAggregates (columnAggregates in React) instead, or give the columns of a view the page defines their Aggregates. A column named both in ColumnAggregates and on its GridColumn shows both sets, the GridColumn's format winning for a figure both give.

React Blazor

Figures are formatted as the column's cells are. To show one another way, give it a format (format in React): a .NET numeric format string such as N0 for no decimals, N1 for one, C0 or #,##0.0, applied in the user's culture. A format shapes a total, average, minimum or maximum; a count and a date keep their own format, and money keeps the base currency's symbol. Figures that share a format can share an entry (QueryAggregate.Sum | QueryAggregate.Average), and users can set their own from a number column's Totals menu.

React Blazor

How the figures are worked out

All of a grid's figures come from one aggregate query, run alongside the page's own, and they're fetched again only when what the grid matches changes or it's refreshed. Money is totaled in the organization's base currency, since amounts in different currencies don't add up to anything. Over Dataverse's limit of 50,000 records for an aggregate, the query is split by date and the parts combined. Column security still applies: a column the user may not read shows a dash, as does a calculated column, which isn't aggregated.

Parameter Reference

Parameter
Description
ColumnName
Required. Logical name of the column; supports dot-notation for aliased linked-entity columns.
TableName
Optional. Logical name of the table whose metadata describes this column. Inherits the grid's TableName when omitted.
Width
Optional CSS length for the column's width.
Align
Optional horizontal alignment override (Align.Start, Align.Center, Align.End). Falls back to the metadata-driven default when omitted.
Title
Optional header label override. Falls back to the column's localized display name.
HeaderTooltip
Optional header tooltip — useful for explaining computed or aliased columns. (Named to avoid the case-insensitive collision with the inherited Tooltip bool parameter on TemplateColumn.)
Visible
Optional. false suppresses the column from the rendered table and from the server projection even when other declared columns are present. Defaults to true.
IsDefaultSortColumn / InitialSortDirection
Optional. Mark a declared column as the grid's initial sort. Sort direction defaults to ascending.
Aggregates
Optional. Figures the totals row shows under the column, over every record the grid matches, each with an optional format: [new(QueryAggregate.Sum, "N0")], with figures sharing a format combined with |. See Totals above.
ChildContent
Optional per-cell template receiving GridRowContext. Renders inside each body cell when supplied; access the row via @@context.PrimaryRecord and (in a SubGrid) the parent via @@context.ParentRecord.
Parameter: ColumnName
Description: Required. Logical name of the column; supports dot-notation for aliased linked-entity columns.
Parameter: TableName
Description: Optional. Logical name of the table whose metadata describes this column. Inherits the grid's TableName when omitted.
Parameter: Width
Description: Optional CSS length for the column's width.
Parameter: Align
Description: Optional horizontal alignment override (Align.Start, Align.Center, Align.End). Falls back to the metadata-driven default when omitted.
Parameter: Title
Description: Optional header label override. Falls back to the column's localized display name.
Parameter: HeaderTooltip
Description: Optional header tooltip — useful for explaining computed or aliased columns. (Named to avoid the case-insensitive collision with the inherited Tooltip bool parameter on TemplateColumn.)
Parameter: Visible
Description: Optional. false suppresses the column from the rendered table and from the server projection even when other declared columns are present. Defaults to true.
Parameter: IsDefaultSortColumn / InitialSortDirection
Description: Optional. Mark a declared column as the grid's initial sort. Sort direction defaults to ascending.
Parameter: Aggregates
Description: Optional. Figures the totals row shows under the column, over every record the grid matches, each with an optional format: [new(QueryAggregate.Sum, "N0")], with figures sharing a format combined with |. See Totals above.
Parameter: ChildContent
Description: Optional per-cell template receiving GridRowContext. Renders inside each body cell when supplied; access the row via @@context.PrimaryRecord and (in a SubGrid) the parent via @@context.ParentRecord.

GridTemplateColumn Parameters

Parameter
Description
Id
Optional stable identifier. When omitted, the framework auto-generates one as __template-{index} based on the template column's position among the other templates. Pass an explicit id when your declarations may reorder dynamically.
Title
Required header label. No bound column metadata to derive a default from.
DependsOn
Optional. Logical Dataverse column names the renderer reads from the row. The framework merges these into the FetchXML projection so the data lands in ctx.Row.PrimaryRecord. Omitted / empty for decorative cells.
SortBy
Optional. Logical column name to sort by when the header is clicked. Omitted = header is not sortable.
Width
Optional CSS length for the column's width.
Align
Optional horizontal alignment override. Defaults to Align.Start (no metadata-driven default since there's no underlying column type).
Tooltip
Optional header tooltip text.
Visible
Optional. false suppresses the column from the rendered table AND drops its DependsOn entries from the server projection. Defaults to true.
ChildContent
Required per-cell template receiving GridTemplateColumnContext. Read the row via ctx.Row.PrimaryRecord (and in a SubGrid the parent via ctx.Row.ParentRecord); use ctx.DependsOnMetadata[name] for per-column metadata when the renderer needs it.
EditChildContent
Optional edit-mode template receiving GridTemplateColumnEditContext. Invoked instead of ChildContent when the grid is in inline-edit mode and the row is mutable. Same row context as the read template plus editCtx.SetValue(name, value) for imperative writes. See Inline-Edit Templates above for the two authoring patterns.
Parameter: Id
Description: Optional stable identifier. When omitted, the framework auto-generates one as __template-{index} based on the template column's position among the other templates. Pass an explicit id when your declarations may reorder dynamically.
Parameter: Title
Description: Required header label. No bound column metadata to derive a default from.
Parameter: DependsOn
Description: Optional. Logical Dataverse column names the renderer reads from the row. The framework merges these into the FetchXML projection so the data lands in ctx.Row.PrimaryRecord. Omitted / empty for decorative cells.
Parameter: SortBy
Description: Optional. Logical column name to sort by when the header is clicked. Omitted = header is not sortable.
Parameter: Width
Description: Optional CSS length for the column's width.
Parameter: Align
Description: Optional horizontal alignment override. Defaults to Align.Start (no metadata-driven default since there's no underlying column type).
Parameter: Tooltip
Description: Optional header tooltip text.
Parameter: Visible
Description: Optional. false suppresses the column from the rendered table AND drops its DependsOn entries from the server projection. Defaults to true.
Parameter: ChildContent
Description: Required per-cell template receiving GridTemplateColumnContext. Read the row via ctx.Row.PrimaryRecord (and in a SubGrid the parent via ctx.Row.ParentRecord); use ctx.DependsOnMetadata[name] for per-column metadata when the renderer needs it.
Parameter: EditChildContent
Description: Optional edit-mode template receiving GridTemplateColumnEditContext. Invoked instead of ChildContent when the grid is in inline-edit mode and the row is mutable. Same row context as the read template plus editCtx.SetValue(name, value) for imperative writes. See Inline-Edit Templates above for the two authoring patterns.

GridRelatedRecordsColumn parameters

Parameter
Description
RelationshipName
The schema name of the relationship: a one-to-many relationship whose parent is the grid's table, or a many-to-many relationship the grid's table takes part in. Required.
Columns
Columns of the related table to load besides its primary name, which is always loaded — for an ItemTemplate or CellTemplate that shows more than names.
SelfReferencingRole
Which side of a self-referencing many-to-many relationship the grid's rows are on. Required for such a relationship; ignored otherwise.
Title
The header label. Defaults to the related table's localized plural name.
Separator
Placed between related records. Defaults to ", ".
Url
Makes each related record a link to this address, with {0} standing for its id.
OnRecordClick
Makes each related record a link that is called with the record when clicked — to open it in a dialog, say.
ItemTemplate
Renders each related record in place of its name. The records are laid out side by side, wrapping.
CellTemplate
Renders the whole cell in place of the list, with the row and its related records.
Width
Column width, as a CSS length like "200px".
Visible
When false, the column isn't shown and its related records aren't loaded.
Searchable
Whether the grid's search box searches the column: a row matches when one of its related records does, by the Columns the column loads, or by its primary name when it loads none. Defaults to true.
Parameter: RelationshipName
Description: The schema name of the relationship: a one-to-many relationship whose parent is the grid's table, or a many-to-many relationship the grid's table takes part in. Required.
Parameter: Columns
Description: Columns of the related table to load besides its primary name, which is always loaded — for an ItemTemplate or CellTemplate that shows more than names.
Parameter: SelfReferencingRole
Description: Which side of a self-referencing many-to-many relationship the grid's rows are on. Required for such a relationship; ignored otherwise.
Parameter: Title
Description: The header label. Defaults to the related table's localized plural name.
Parameter: Separator
Description: Placed between related records. Defaults to ", ".
Parameter: Url
Description: Makes each related record a link to this address, with {0} standing for its id.
Parameter: OnRecordClick
Description: Makes each related record a link that is called with the record when clicked — to open it in a dialog, say.
Parameter: ItemTemplate
Description: Renders each related record in place of its name. The records are laid out side by side, wrapping.
Parameter: CellTemplate
Description: Renders the whole cell in place of the list, with the row and its related records.
Parameter: Width
Description: Column width, as a CSS length like "200px".
Parameter: Visible
Description: When false, the column isn't shown and its related records aren't loaded.
Parameter: Searchable
Description: Whether the grid's search box searches the column: a row matches when one of its related records does, by the Columns the column loads, or by its primary name when it loads none. Defaults to true.