DevExtreme Vue - Overview

The Lookup is a widget that allows an end user to search for an item in a collection shown in a drop-down menu.

View Demo

The following code adds the Lookup widget to your page. The simplest configuration requires only a dataSource to be specified. In addition, you can define the placeholder to be displayed when the Lookup input field is empty.

  • <template>
  • <DxLookup
  • :data-source="dataSource"
  • placeholder="Select a product..."
  • />
  • </template>
  •  
  • <script>
  • import 'devextreme/dist/css/dx.common.css';
  • import 'devextreme/dist/css/dx.light.css';
  •  
  • import { DxLookup } from 'devextreme-vue/lookup';
  •  
  • export default {
  • components: {
  • DxLookup
  • },
  • data() {
  • return {
  • dataSource: [
  • 'HD Video Player',
  • 'SuperHD Video Player',
  • 'SuperPlasma 50',
  • // ...
  • ]
  • };
  • }
  • }
  • </script>

If your data is an array of objects, specify:

  • valueExpr
    The data field whose value will be written into the value option.
  • displayExpr
    The data field whose value will be displayed within the inner List widget and in the input field of the Lookup.
  • <template>
  • <DxLookup
  • :data-source="lookupData"
  • value-expr="id"
  • display-expr="country"
  • />
  • </template>
  •  
  • <script>
  • import 'devextreme/dist/css/dx.common.css';
  • import 'devextreme/dist/css/dx.light.css';
  •  
  • import { DxLookup } from 'devextreme-vue/lookup';
  •  
  • export default {
  • components: {
  • DxLookup
  • },
  • data() {
  • return {
  • lookupData: [
  • { id: 1, country: 'Afghanistan' },
  • { id: 2, country: 'Albania' },
  • // ...
  • ]
  • };
  • }
  • }
  • </script>
See Also