A list of values (LOV) lets a person pick a value for a field from a data source.

Registering

manager.LOV.RegisterLOV("Ord", "Qty", new LOVDefinition
{
    LOVName = "QtyLov", DataSourceName = "DemoDb",
    EntityName = "orderlines", DisplayField = "Qty", ReturnField = "Id",
});

LOVDefinition

GroupMembers
IdentityLOVName, Title, DataSourceName, EntityName, DisplayField, ReturnField
ListsColumns, Filters, WhereClause, OrderByClause, RelatedFieldMappings
SearchAllowSearch (true), SearchMode (Contains)
DisplayWidth (600), Height (400), AllowMultiSelect, ShowRowNumbers (true), AutoSizeColumns (true)
BehaviorAutoRefresh (true), ValidationType (ListOnly), AutoDisplay, AutoDisplayMinChars (2), AutoPopulateRelatedFields (true)
CacheUseCache (true), CacheDurationMinutes (30)

Fluent members are AddColumn, MapField and AddFilter. Factories are Create and CreateLookup.

LOVSearchMode is Contains, StartsWith, EndsWith or Exact. A LOVColumn has FieldName, DisplayName, Width (100), Visible, Searchable, Format, Alignment (Left, Center, Right), SortOrder and SortAscending. Factories: Create, Hidden, Numeric, Date.

Validation modes

LOVValidationType is ListOnly, Unrestricted or Validated. Only Unrestricted skips the check. An empty value is valid. Otherwise the value is compared, ignoring case, with the values of the ReturnField. When it is not found the message is "Value '{value}' not found in List of Values" with up to five suggestions, and the LOVValidationFailed event is raised.

The LOV manager

ILOVManager offers RegisterLOV, UnregisterLOV, HasLOV, GetLOV, GetBlockLOVs, LoadLOVDataAsync, FilterLOVData, ValidateLOVValueAsync, GetRelatedFieldValues, FindRecordByValueAsync, cache and refresh methods, and the events LOVDataLoaded and LOVValidationFailed.

In the hosts

  • F9 shows the list for the current field.
  • WinFormBlockHost.ShowLovAsync(fieldName, searchText) opens WinFormLovDialog. On WPF the dialog is WpfLovPickerDialog.
  • LovDialogPresenter is a replaceable function, so a host can show its own picker.
  • ApplyLovSelectionAsync writes the return value and the related fields. When AutoPopulateRelatedFields is false the related fields are skipped, but the return value is always set.
  • Both dialogs use AllowMultiSelect. The WPF dialog uses ShowRowNumbers. The WPF combo presenter uses AutoDisplay and AutoDisplayMinChars.