SubGrid

The SubGrid component displays Dataverse records related to a parent record via a specified relationship. It must be placed inside a RecordContext and requires a RelationshipName parameter that specifies which relationship to use.

Relationship Types

SubGrid supports both one-to-many (1:N) and many-to-many (N:N) relationships. The component automatically detects the relationship type and adjusts its behavior accordingly.

  • For 1:N relationships, the grid displays records from the related table that reference the parent record. Toolbar buttons like NewRecordGridButton, EditRecordGridButton, and DeleteRecordGridButton are used to create, edit, and delete related records.
  • For N:N relationships, the grid displays associated records. Toolbar buttons like LinkExistingRecordGridButton and UnlinkExistingRecordGridButton are used to associate and disassociate records. Create and delete operations are automatically converted to associate and disassociate requests.

Views

Use ViewIds to specify which views are available in the view selector dropdown, and DefaultViewId to set the initially selected view. If neither is provided, the grid automatically loads all public views for the related table. You can also provide CustomViewDefinitions with inline FetchXML to define views directly in code.

<SubGrid RelationshipName="contact_customer_accounts"
         ViewIds="_contactViews"
         DefaultViewId="@(new Guid("..."))">
</SubGrid>

@code {
    private List<Guid> _contactViews = new List<Guid>
    {
        new Guid("..."),
        new Guid("..."),
    };
}

Toolbar Buttons

Add buttons to the grid toolbar using the Buttons render fragment. See the Grid Buttons documentation for detailed configuration options including dialog positioning, wizard forms, and save behavior. The following built-in buttons are available:

  • NewRecordGridButton — Opens a dialog form to create a new related record (1:N)
  • EditRecordGridButton — Opens a dialog form to edit the selected record
  • DeleteRecordGridButton — Deletes selected records
  • LinkExistingRecordGridButton — Associates an existing record via a N:N relationship
  • UnlinkExistingRecordGridButton — Disassociates selected records from a N:N relationship
  • NavigateNewRecordGridButton — Navigates to a URL to create a new record
  • NavigateEditRecordGridButton — Navigates to a URL to edit the selected record
<!-- 1:N relationship buttons -->
<SubGrid RelationshipName="contact_customer_accounts">
    <Buttons>
        <NewRecordGridButton TForm="NewContactForm" />
        <EditRecordGridButton TForm="EditContactForm" />
        <DeleteRecordGridButton />
    </Buttons>
</SubGrid>

<!-- N:N relationship buttons -->
<SubGrid RelationshipName="ppp_Account_ppp_Region_ppp_Region">
    <Buttons>
        <LinkExistingRecordGridButton />
        <UnlinkExistingRecordGridButton />
    </Buttons>
</SubGrid>

Inline Editing

Set AllowEdit="true" to enable a settings toggle that lets users switch to inline editing mode. When enabled, editable columns render as form controls directly in the grid. Inline editing is only supported for 1:N relationships.

<SubGrid RelationshipName="contact_customer_accounts"
         AllowEdit="true">
    <Buttons>
        <NewRecordGridButton TForm="NewContactForm" />
        <EditRecordGridButton TForm="EditContactForm" />
    </Buttons>
</SubGrid>

Paging & Search

The grid supports paged navigation with configurable page sizes via DefaultItemsPerPage and PageSizes. Search is enabled by default and can be disabled with AllowSearch="false".

<SubGrid RelationshipName="contact_customer_accounts"
         DefaultItemsPerPage="10"
         PageSizes="@(new[] { 10, 25, 50 })"
         AllowSearch="false">
</SubGrid>

SubGrid (One to Many Relationship)

Here is an example that demonstrates the use of a SubGrid component for a 1:N relationship.
The grids below are linked to an 'Account' record.

Example
All ContactsMy Contacts
New
All ContactsMy Contacts
New

Page size

102050100
Full Name
Mobile Phone
Email
Company Name
Age
Brandon Young(469) 555-7205brandon.young@email.comApex Industries18
Charles Ross(303) 555-9528charles.ross@email.comApex Industries67
Jacob King(503) 555-8573jacob.king@email.comApex Industries61
Laura Allen(858) 555-3462laura.allen@email.comApex Industries50
Michelle Thompson(702) 555-6419michelle.thompson@email.comApex Industries55
Ryan Rodriguez(901) 555-7346ryan.rodriguez@email.comApex Industries20
Victoria Morgan(954) 555-2653victoria.morgan@email.comApex Industries59

SubGrid (Many to Many Relationship)

Here is an example that demonstrates the use of a SubGrid component for a N:N relationship.

Example
Active RegionsInactive Regions
Link Existing
Active RegionsInactive Regions
Link Existing

Page size

102050100
Name
No records found.

SubGrid Class

Parameters

Name
Type
Default
Description
AllowChangingItemsPerPagebool
True
When true, the user can change the number of items displayed per page.
AllowEditbool
False
Should the option be available for the user to turn on inline editing for the grid.
AllowEditOnRowDoubleClickbool
True
If a button is present that has the set to true,
and this is set to 'true', then the event delegate will be called for the record.
AllowSearchbool
True
Should the user be allowed to search the grid.
BorderVisiblebool
True
Controls whether a visible border is rendered around the grid.
ButtonsRenderFragment?
Optional render fragment used to define the button toolbar displayed above the grid.
CustomViewDefinitionsList<GridViewDefinition>?
Custom views to display in the dropdown.
DefaultItemsPerPageint
50
Default number of records to load on a page.
DefaultViewIdGuid?
Id of the view that the grid should display upon initial load.
Editablebool
False
Is inline editing turned on for the grid.
FullSizebool
False
When true, the grid expands to fill all available vertical space instead of using a fixed minimum height.
HidePagingbool
False
Force the page size and paging components to be hidden.
Only do this when the number of items is known and the page size is set to something greater than the item count.
IsDirtybool
False
Indicates whether the grid has unsaved create, update, or delete operations pending.
MaxHeightstring?
Max Height that the grid control should expand to.
MinHeightstring?
250px
Minimum height that the grid control should occupy.
ModeGridMode
RecordSelection
Sets the behavioural mode of the grid, such as default interaction or record-selection mode.
OnBeforeQueryFunc<FetchXMLBuilder, Task<FetchXMLBuilder>>?
Optional callback to apply additional filter criteria to the FetchXML query before it is executed.
PageSizesIEnumerable<int>
Collection of available page sizes for the grid.
PagingModeGridPagingMode
Paged
Determines whether the grid uses traditional paging or infinite-scroll virtualisation.
RecordTableRecord?
The parent record supplied via a cascading parameter; related records are filtered by this record's identity.
RelationshipNamestring
The schema name of the relationship used to filter and display related records in this sub-grid.
SelectedRecordsIEnumerable<TableRecord>
Records that are currently selected in the Grid.
SelectedViewQueryParameterstring?
Query parameter to persist the selected view to.
SelectFromEntireRowbool
True
When true, clicking anywhere on a row selects it; when false, only the checkbox selects the row.
SelectModeDataGridSelectMode
Multiple
Controls whether the grid allows single or multiple row selection.
Titlestring?
Name to display when the view dropdown is not displayed.
ViewIdsIEnumerable<Guid>?
List of id's of the views that the grid should limit to in the view dropdown.
ViewSortViewSort
NameAscending
Sort order of the views in the view dropdown.
Name: AllowChangingItemsPerPage
Type: bool
Default: True
Description: When true, the user can change the number of items displayed per page.
Name: AllowEdit
Type: bool
Default: False
Description: Should the option be available for the user to turn on inline editing for the grid.
Name: AllowEditOnRowDoubleClick
Type: bool
Default: True
Description: If a button is present that has the set to true,
and this is set to 'true', then the event delegate will be called for the record.
Name: AllowSearch
Type: bool
Default: True
Description: Should the user be allowed to search the grid.
Name: BorderVisible
Type: bool
Default: True
Description: Controls whether a visible border is rendered around the grid.
Name: Buttons
Type: RenderFragment?
Description: Optional render fragment used to define the button toolbar displayed above the grid.
Name: CustomViewDefinitions
Type: List<GridViewDefinition>?
Description: Custom views to display in the dropdown.
Name: DefaultItemsPerPage
Type: int
Default: 50
Description: Default number of records to load on a page.
Name: DefaultViewId
Type: Guid?
Description: Id of the view that the grid should display upon initial load.
Name: Editable
Type: bool
Default: False
Description: Is inline editing turned on for the grid.
Name: FullSize
Type: bool
Default: False
Description: When true, the grid expands to fill all available vertical space instead of using a fixed minimum height.
Name: HidePaging
Type: bool
Default: False
Description: Force the page size and paging components to be hidden.
Only do this when the number of items is known and the page size is set to something greater than the item count.
Name: IsDirty
Type: bool
Default: False
Description: Indicates whether the grid has unsaved create, update, or delete operations pending.
Name: MaxHeight
Type: string?
Description: Max Height that the grid control should expand to.
Name: MinHeight
Type: string?
Default: 250px
Description: Minimum height that the grid control should occupy.
Name: Mode
Type: GridMode
Default: RecordSelection
Description: Sets the behavioural mode of the grid, such as default interaction or record-selection mode.
Name: OnBeforeQuery
Type: Func<FetchXMLBuilder, Task<FetchXMLBuilder>>?
Description: Optional callback to apply additional filter criteria to the FetchXML query before it is executed.
Name: PageSizes
Type: IEnumerable<int>
Description: Collection of available page sizes for the grid.
Name: PagingMode
Type: GridPagingMode
Default: Paged
Description: Determines whether the grid uses traditional paging or infinite-scroll virtualisation.
Name: Record
Type: TableRecord?
Description: The parent record supplied via a cascading parameter; related records are filtered by this record's identity.
Name: RelationshipName
Type: string
Description: The schema name of the relationship used to filter and display related records in this sub-grid.
Name: SelectedRecords
Type: IEnumerable<TableRecord>
Description: Records that are currently selected in the Grid.
Name: SelectedViewQueryParameter
Type: string?
Description: Query parameter to persist the selected view to.
Name: SelectFromEntireRow
Type: bool
Default: True
Description: When true, clicking anywhere on a row selects it; when false, only the checkbox selects the row.
Name: SelectMode
Type: DataGridSelectMode
Default: Multiple
Description: Controls whether the grid allows single or multiple row selection.
Name: Title
Type: string?
Description: Name to display when the view dropdown is not displayed.
Name: ViewIds
Type: IEnumerable<Guid>?
Description: List of id's of the views that the grid should limit to in the view dropdown.
Name: ViewSort
Type: ViewSort
Default: NameAscending
Description: Sort order of the views in the view dropdown.

Events

Name
Type
Description
EditableChangedEventCallback<bool>
Callback invoked when the inline editing state changes.
SelectedRecordsChangedEventCallback<IEnumerable<TableRecord>>
Callback invoked when the selected records collection changes.
Name: EditableChanged
Type: EventCallback<bool>
Description: Callback invoked when the inline editing state changes.
Name: SelectedRecordsChanged
Type: EventCallback<IEnumerable<TableRecord>>
Description: Callback invoked when the selected records collection changes.

Methods

Name
Parameters
Type
Description
ClearSelectionAsyncTask
Clears all currently selected rows.
RefreshAsyncbool forceRefresh
Task
Instructs the grid to re-fetch and render the current data from the supplied data source.
Validatebool
Validates all editable rows in the grid.
Name: ClearSelectionAsync
Type: Task
Description: Clears all currently selected rows.
Name: RefreshAsync
Parameters: bool forceRefresh
Type: Task
Description: Instructs the grid to re-fetch and render the current data from the supplied data source.
Name: Validate
Type: bool
Description: Validates all editable rows in the grid.