How to: Add a Search Action to Lookup Property Editors and Link Pop-up Windows
- 3 minutes to read
Lookup Property Editors that display reference properties contain a list of existing objects of the specified type in the drop-down menu. Similarly, the Link Action’s pop-up windows display a list of available objects of the specified type. The following image demonstrates both the Lookup Property Editor’s drop-down window and the Link Action’s pop-up window:
- ASP.NET Core Blazor
- Windows Forms
This topic explains how to enable the Search functionality that allows you to quickly find the required object when there are many objects to be shown.
Note
In XAF ASP.NET Core Blazor applications, the Search functionality is always available in the Link Action’s pop-up window.
Search Functionality
- ASP.NET Core Blazor
- Windows Forms
- ASP.NET Web Forms
The Search button executes FullTextFilterAction of the FilterController. It looks for objects whose property values (string representations) include the value specified by the user. Properties that take part in search are listed in the Views | <ListView> node that defines the List View. They can be visible or invisible, persistent or non-persistent. For more information, refer to the following topic: FilterController.
Automatic Activation
In Windows Forms and ASP.NET Web Forms applications, XAF automatically enables the Search functionality when a List View in a Lookup Property Editor or Link Action’s pop-up window contains more than 25 objects.
You can specify a different limit in the IModelOptions.LookupSmallCollectionItemCount property of the Application Model‘s Options node.
In Code
To enable the Search functionality in the Lookup Property Editor or Link Action’s pop-up window with any number of objects in the List View’s collection source, apply the LookupEditorModeAttribute to the required property (a reference of collection property). Specify one of the following modes for the corresponding Lookup Property Editor or Link Action’s pop-up window:
Mode | Loaded objects | Search functionality |
---|---|---|
| ASP.NET Core Blazor: All objects of the specified type. Windows Forms, ASP.NET Web Forms: None if the object count in the property’s data source collection is less than the value of the LookupSmallCollectionItemCount property. | ASP.NET Core Blazor: Disabled. Windows Forms, ASP.NET Web Forms: Disabled if the object count in the property’s data source collection is less than the value of the LookupSmallCollectionItemCount property. |
| All objects of the specified type. | Not enabled. |
| None. | Enabled. |
| All objects of the specified type. | Enabled. |
To set the required mode, pass the corresponding value as the LookupEditorModeAttribute
‘s parameter.
In Application Model
In the Model Editor, set the LookupEditorMode property of the BOModel | <Class> | OwnMembers | <Member> node to the required value.