DevExtreme v24.2 is now available.

Explore our newest features/capabilities and share your thoughts with us.

Your search did not match any results.

React Lookup - Basics

The Lookup component allows users to search through its drop-down list and select a single item. The drop-down list can be grouped by category.

DevExtreme Accessibility Compliance
DevExtreme component libraries meet a variety of WCAG and Section 508 compliance standards. To assess this demo’s accessibility level, click the Run AXE® Validation button to launch the AXE® web accessibility evaluation tool.
All trademarks or registered trademarks are property of their respective owners. AXE® Terms of Use
The overall accessibility level of your application depends on the Lookup features used.
To give you the ability to edit code on the fly, the demo uses SystemJS. For this reason, launching the demo takes some time. We strongly recommend that you do not use this approach in real projects.
Backend API

Bind the Component to Data

To bind the component to data, use one of these properties:

  • items[]
    Accepts a local data array (see the Simple Lookup code below).

  • dataSource
    Accepts a local data array or a DataSource object. This object works with local and remote arrays and allows you to shape data. In this demo, a DataSource instance is configured to group a local array of objects (see the Grouped Lookup code below).

Both properties work with arrays of primitives or objects. If you use objects, specify the following properties:

  • valueExpr
    A data field that contains unique values used to identify items.

  • displayExpr
    A data field whose values should be displayed in the drop-down list.

When a user selects an item, the Lookup component saves the corresponding value from the valueExpr data field in the value property. You can also specify the value property in code to preselect an item as shown in the Simple Lookup use case.

Group Data

You can group data items in the drop-down list.

If the data source contains ungrouped data items, use the DataSource's group property to specify the data field to group by.

The Lookup component can also work with initially grouped data items. In this case, the data array should contain objects with the key and items fields:

If data objects are grouped but use other field names, implement the DataSource's map function to create key and items field mappings.

NOTE

Only one-level grouping is supported.

Regardless of the data source structure, enable the grouped property.

Configure the Drop-Down List

The Lookup component uses the Popover component as a drop-down list. To customize the Popover, use the dropDownOptions property. It accepts an object with Popover properties. Alternatively, you can set the usePopover property to false to display lookup items in a pop-up window.