LookupEdit
The LookupEdit component renders a Dataverse lookup (reference) column, allowing users to search for and select a related record.
<LookupEdit ColumnName="primarycontactid" />
Editor Type
Set EditorType to choose the rendering style: LookupEditType.AutoComplete (default) provides type-ahead search, LookupEditType.Dropdown shows a fixed list, and LookupEditType.RadioButtons displays all options as radio buttons.
<!-- Autocomplete with type-ahead (default) -->
<LookupEdit ColumnName="primarycontactid" EditorType="LookupEditType.AutoComplete" />
<!-- Dropdown with fixed list -->
<LookupEdit ColumnName="primarycontactid" EditorType="LookupEditType.Dropdown" />
<!-- Radio buttons -->
<LookupEdit ColumnName="primarycontactid"
EditorType="LookupEditType.RadioButtons"
RadioButtonOrientation="ComponentOrientation.Vertical" />
Views
Use ViewIds to constrain which views are available in the advanced search dialog. Use DefaultViewId to set which view is used for searching. The ViewIds parameter is a Dictionary<string, List<Guid>> keyed by table name, supporting polymorphic lookups that target multiple tables.
<LookupEdit ColumnName="primarycontactid"
ViewIds="_contactViews"
DefaultViewId="@(new Guid("..."))" />
@code {
private Dictionary<string, List<Guid>> _contactViews = new()
{
{ "contact", new List<Guid> { new Guid("...") } }
};
}
Polymorphic Lookups
For lookup columns that target multiple tables, use DefaultTable to set which table is selected by default in the table selector.
<LookupEdit ColumnName="parentcustomerid" DefaultTable="account" />
LookupEdit
Here is an example that demonstrates the use of a LookupEdit component.
LookupEdit (Extended Properties)
This demonstrates the most common properties that are availabe to set on the LookupEdit.
LookupEdit Class
Parameters
Name | Type | Default | Description |
|---|---|---|---|
ChildContent | RenderFragment? | Child content of the component | |
ColumnName | string | Column logical name to bind the editor to from the table record. | |
DefaultTable | string? | Optionally specify which table should be set as the default table to search when the lookup is linked to a customer or polymorphic column type. | |
DefaultViewId | Guid? | Specify which view should be used for searching, otherwise the Lookup view will be used. | |
Description | string? | Description to be displayed in the tooltip. | |
Disabled | bool? | Should the editor be disabled. | |
DisplayLabelWhenAvailable | bool | True | Specifies whether to display a lable if available. |
DisplayNullChoice | bool | True | Only applicable when the == RadioButtons. Displays a radio button that represents a NULL value. |
DisplayTooltipWhenAvailable | bool | True | Specifies whether to display a tooltip if available. |
DisplayValidationErrorMessage | bool | True | Should a validation error message be displayed when the component fails validation? |
EditorType | LookupEditType | AutoComplete | Type of editor to render for selecting values. |
IsVisible | bool | True | Is the editor visible. |
Label | string? | Text to be displayed as a label for the editor. | |
MaxRecordsReturned | int | 20 | That maximum number of records to return when querying Dataverse. This also limits the records displayed when the is equal to or . |
RadioButtonOrientation | ComponentOrientation | Vertical | Orientation of the radio buttons. Only valid when the is set to . |
ReadOnly | bool? | Should the editor be read-only. | |
Required | bool? | Should the value be required. | |
Value | LookupEditValue? | Gets or sets the editor's currently selected lookup record. | |
ViewIds | Dictionary<string, List<Guid>>? | Optionally constrain which views can be displayed in the 'Advanced Search' dialog. The key in the dictionary is the table name. |
ChildContentColumnNameDefaultTablelinked to a customer or polymorphic column type.
DefaultViewIdDescriptionDisabledDisplayLabelWhenAvailableDisplayNullChoiceDisplays a radio button that represents a NULL value.
DisplayTooltipWhenAvailableDisplayValidationErrorMessageEditorTypeIsVisibleLabelMaxRecordsReturnedis equal to or .
RadioButtonOrientationReadOnlyRequiredValueViewIdsThe key in the dictionary is the table name.
Events
Name | Type | Description |
|---|---|---|
ValueChanged | EventCallback<ColumnValueBase> | Gets or sets a callback that updates the bound value. |
ValueChangedMethods
Name | Parameters | Type | Description |
|---|---|---|---|
GetValidationErrors | List<string> | Returns a collection of the current validation errors. |
GetValidationErrors