Skip to main content

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
XAF ASP.NET Core Blazor Lookup Property Editor and Link Popup Window, DevExpress
Windows Forms
XAF Windows Forms Lookup Property Editor and Link Popup Window, DevExpress

This topic explains how to enable the Search functionality that allows you to quickly find required objects the many displayed.

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

XAF ASP.NET Core Blazor Look-up Property Editor in Search Mode, DevExpress

XAF ASP.NET Core Blazor Look-up Property Editor Search Pop-up Window, DevExpress

Windows Forms
XAF Windows Forms Look-up Property Editor in Search Mode, DevExpress

The Search button executes FullTextFilterAction of the FilterController. It looks for objects where property values (string representations) include the value specified by the user. Properties are listed in the Views | <ListView> node that defines the List View. They can be visible or hidden, persistent or non-persistent. For more information, refer to the following topic: FilterController.

Automatic Activation (Windows Forms)

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.

XAF LookupSmallCollectionItemCount Property in Model Editor, DevExpress

Enable Search Functionality 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

Auto

ASP.NET Core Blazor: All objects of the specified type.

Windows 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. Only native DxComboBox<TData, TValue> search is available.

Windows Forms: Disabled if the object count in the property’s data source collection is less than the value of the LookupSmallCollectionItemCount property.

AllItems

All objects of the specified type.

Only native DxComboBox<TData, TValue> search is available.

Search

None.

Enabled.

AllItemsWithSearch

All objects of the specified type.

Enabled.

To set the required mode, pass the corresponding value as the LookupEditorModeAttribute‘s parameter.

File: SolutionName.Module/BusinessObjects/Employee.cs

using DevExpress.Persistent.Base;

namespace SolutionName.Module.BusinessObjects;

public class Employee : BaseObject {
    // ...
    [LookupEditorMode(LookupEditorMode.AllItemsWithSearch)]
    public Department Department {
      // ...
    }
  }

To avoid loading large datasets at application startup, enable the View Mode display style for Lookup Property Editors that use AllItems data loading mode. For more information, refer to the following help topic: Reference (Foreign Key, Complex Type) Properties.

Enable Search Functionality in Model Editor

In the Model Editor, set the LookupEditorMode property of the BOModel | <Class> | OwnMembers | <Member> node to the required value.