React Autocomplete - Configure Search Parameters

The AutoComplete can provide suggestions in two different modes: 'contains' (by default) and 'startswith'. You can use the searchMode property to change the mode.

Code
  • import React from 'react';
  • import 'devextreme/dist/css/dx.fluent.blue.light.css';
  •  
  • import { Autocomplete } from 'devextreme-react/autocomplete';
  •  
  • const autocompleteData = [
  • { country: 'Afghanistan', capital: 'Kabul' },
  • { country: 'Albania', capital: 'Tirana' },
  • // ...
  • ];
  •  
  • export default function App() {
  • return (
  • <Autocomplete
  • dataSource={autocompleteData}
  • valueExpr="country"
  • searchMode="startswith"
  • />
  • );
  • }

By default, the AutoComplete UI component starts providing suggestions once an end user types the first character. To increase the number of characters that triggers suggestions, use the minSearchLength property.

Code
  • import React from 'react';
  • import 'devextreme/dist/css/dx.fluent.blue.light.css';
  •  
  • import { Autocomplete } from 'devextreme-react/autocomplete';
  •  
  • export default function App() {
  • return (
  • <Autocomplete minSearchLength={3}/>
  • );
  • }

You can also specify the time interval the UI component should wait before providing suggestions. Assign this time interval measured in milliseconds to the searchTimeout property.

Code
  • import React from 'react';
  • import 'devextreme/dist/css/dx.fluent.blue.light.css';
  •  
  • import { Autocomplete } from 'devextreme-react/autocomplete';
  •  
  • export default function App() {
  • return (
  • <Autocomplete searchTimeout={500}/>
  • );
  • }
See Also