Search results

AutoCompleteComponent

The AutoComplete component provides the matched suggestion list when type into the input, from which the user can select one.

<AutoCompleteComponent dataSource={data}/>

Properties

actionFailureTemplate

string | Function

Accepts the template and assigns it to the popup list content of the component when the data fetch request from the remote server fails.

Defaults to ‘Request failed’

allowCustom

boolean

Specifies whether the component allows user defined value which does not exist in data source.

Defaults to true

allowObjectBinding

boolean

Defines whether the object binding is allowed or not in the component.

Defaults to false

autofill

boolean

Specifies whether suggest a first matched item in input when searching. No action happens when no matches found.

Defaults to false

cssClass

string

Sets CSS classes to the root element of the component that allows customization of appearance.

Defaults to null

dataSource

{ [key: string]: Object }[] | DataManager | string[] | number[] | boolean[]

Accepts the list items either through local or remote service and binds it to the component. It can be an array of JSON Objects or an instance of DataManager.

Defaults to []

enablePersistence

boolean

Enable or disable persisting component’s state between page reloads. If enabled, following list of states will be persisted.

  1. value

Defaults to false

enableRtl

boolean

Enable or disable rendering component in right to left direction.

Defaults to false

enableVirtualization

boolean

Defines whether to enable virtual scrolling in the component.

Defaults to false

enabled

boolean

Specifies a value that indicates whether the component is enabled or not.

Defaults to true

fields

FieldSettingsModel

The fields property maps the columns of the data table and binds the data to the component.

  • text - Maps the text column from data table for each list item
  • value - Maps the value column from data table for each list item
  • iconCss - Maps the icon class column from data table for each list item
  • groupBy - Group the list items with it’s related items by mapping groupBy field
  import './App.css';
  import * as React from 'react';
  import { AutoCompleteComponent  } from '@syncfusion/ej2-react-dropdowns';

  class App extends React.Component {
    public countries: { [key: string]: Object; }[] = [
      { Name: "Australia", Code: "AU" },
      { Name: "Bermuda", Code: "BM" },
      { Name: "Canada", Code: "CA" },
      { Name: "Cameroon", Code: "CM" },
      { Name: "Denmark", Code: "DK" }
    ];
    public fields = { value: 'Name' };
    public render() {
      return (<AutoCompleteComponent  dataSource={this.countries}  fields={this.fields} placeholder={"e.g. Australia"}  />);
    }
  }

  export default App;

For more details about the field mapping refer to Data binding documentation.

Defaults to { value: null, iconCss: null, groupBy: null}

filterType

FilterType

Determines on which filter type, the component needs to be considered on search action. The available FilterType and its supported data types are

FilterType
Description
Supported Types
StartsWith
Checks whether a value begins with the specified value.
String
EndsWith
Checks whether a value ends with specified value.


String
Contains
Checks whether a value contains with specified value.


String

The default value set to Contains, all the suggestion items which contain typed characters to listed in the suggestion popup.

Defaults to ‘Contains’

floatLabelType

FloatLabelType

Specifies whether to display the floating label above the input element. Possible values are:

  • Never: The label will never float in the input when the placeholder is available.
  • Always: The floating label will always float above the input.
  • Auto: The floating label will float above the input after focusing or entering a value in the input.

Defaults to Syncfusion.EJ2.Inputs.FloatLabelType.Never

footerTemplate

string | Function

Accepts the template design and assigns it to the footer container of the popup list.

For more details about the available template options refer to Template documentation.

Defaults to null

groupTemplate

string | Function

Accepts the template design and assigns it to the group headers present in the popup list.

Defaults to null

headerTemplate

string | Function

Accepts the template design and assigns it to the header container of the popup list.

For more details about the available template options refer to Template documentation.

Defaults to null

highlight

boolean

When set to ‘true’, highlight the searched characters on suggested list items.

For more details about the highlight refer to Custom highlight search documentation.

Defaults to false

htmlAttributes

{ [key: string]: string }

Allows additional HTML attributes such as title, name, etc., and accepts n number of attributes in a key-value pair format.

import './App.css';
import * as React from 'react';
import { AutoCompleteComponent  } from '@syncfusion/ej2-react-dropdowns';

class App extends React.Component {
  public countries: { [key: string]: Object; }[] = [
    { Name: "Australia", Code: "AU" },
    { Name: "Bermuda", Code: "BM" },
    { Name: "Canada", Code: "CA" },
    { Name: "Cameroon", Code: "CM" },
    { Name: "Denmark", Code: "DK" }
  ];
  public fields = { value: 'Name' };
  public htmlAttributes = { name: "country", maxlength: "2", title: "AutoComplete" };
  public render() {
    return (<AutoCompleteComponent  dataSource={this.countries}  fields={this.fields} placeholder={"e.g. Australia"} htmlAttributes={this.htmlAttributes}  />);
  }
}

export default App;

Defaults to {}

ignoreAccent

boolean

ignoreAccent set to true, then ignores the diacritic characters or accents when filtering.

ignoreCase

boolean

When set to ‘false’, consider the case-sensitive on performing the search to find suggestions. By default consider the casing.

Defaults to true

itemTemplate

string | Function

Accepts the template design and assigns it to each list item present in the popup. We have built-in template engine which provides options to compile template string into a executable function. For EX: We have expression evolution as like ES6 expression string literals.

Defaults to null

locale

string

Overrides the global culture and localization value for this component. Default global culture is ‘en-US’.

Defaults to ‘en-US’

minLength

number

Allows you to set [`the minimum search character length’] (../../auto-complete/filtering#limit-the-minimum-filter-character), the search action will perform after typed minimum characters.

Defaults to 1

noRecordsTemplate

string | Function

Accepts the template design and assigns it to popup list of component when no data is available on the component.

Defaults to ‘No records found’

placeholder

string

Specifies a short hint that describes the expected value of the DropDownList component.

Defaults to null

popupHeight

string | number

Specifies the height of the popup list.

For more details about the popup configuration refer to Popup Configuration documentation.

Defaults to ‘300px’

popupWidth

string | number

Specifies the width of the popup list. By default, the popup width sets based on the width of the component.

For more details about the popup configuration refer to Popup Configuration documentation.

Defaults to ‘100%’

query

Query

Accepts the external query that execute along with data processing.

import './App.css';
import * as React from 'react';
import { AutoCompleteComponent  } from '@syncfusion/ej2-react-dropdowns';
import { Query, DataManager, ODataV4Adaptor } from '@syncfusion/ej2-data';

class App extends React.Component {
  public dataSource: DataManager = new DataManager({
    url: 'https://services.odata.org/V4/Northwind/Northwind.svc/Customers',
    adaptor: new ODataV4Adaptor,
    crossDomain: true
  });
  public fields: Object =  { value: 'ContactName' };
  public query: Query = new Query().select(['ContactName']).take(6);
  public render() {
    return (<AutoCompleteComponent query={this.query} dataSource={this.dataSource}  fields={this.fields} placeholder={"Find a customer"}  />);
  }
}

export default App;

Defaults to null

readonly

boolean

When set to true, the user interactions on the component are disabled.

Defaults to false

showClearButton

boolean

Specifies whether to show or hide the clear button. When the clear button is clicked, value, text, and index properties are reset to null.

Defaults to true

showPopupButton

boolean

Allows you to either show or hide the popup button on the component.

Defaults to false

sortOrder

SortOrder

Specifies the sortOrder to sort the data source. The available type of sort orders are

  • None - The data source is not sorting.
  • Ascending - The data source is sorting with ascending order.
  • Descending - The data source is sorting with descending order.

Defaults to null

suggestionCount

number

Supports the specified number of list items on the suggestion popup.

Defaults to 20

value

number | string | boolean | any | null

Gets or sets the value of the selected item in the component.

Defaults to null

width

string | number

Specifies the width of the component. By default, the component width sets based on the width of its parent container. You can also set the width in pixel values.

Defaults to ‘100%’

zIndex

number

specifies the z-index value of the component popup element.

Defaults to 1000

Methods

addItem

Adds a new item to the combobox popup list. By default, new item appends to the list as the last item, but you can insert based on the index parameter.

Parameter Type Description
items { [key: string]: Object }[] | { [key: string]: Object } | string | boolean | number | string[] | boolean[] | number[] Specifies an array of JSON data or a JSON data.
itemIndex (optional) number Specifies the index to place the newly added item in the popup list.

Returns void

clear

Allows you to clear the selected values from the component.

Returns void

destroy

Removes the component from the DOM and detaches all its related event handlers. Also it removes the attributes and classes.

Returns void

filter

To filter the data from given data source by using query

Parameter Type Description
dataSource { [key: string]: Object }[] | DataManager | string[] | number[] | boolean[] Set the data source to filter.
query (optional) Query Specify the query to filter the data.
fields (optional) FieldSettingsModel Specify the fields to map the column in the data table.

Returns void

focusIn

Sets the focus to the component for interaction.

Returns void

focusOut

Moves the focus from the component if the component is already focused.

Returns void

getDataByValue

Gets the data Object that matches the given value.

Parameter Type Description
value string | number | boolean Specifies the value of the list item.

Returns { [key: string]: Object } | string | number | boolean

getItems

Gets all the list items bound on this component.

Returns Element[]

hidePopup

Hides the popup if it is in open state.

Returns void

hideSpinner

Hides the spinner loader.

Returns void

showPopup

Search the entered text and show it in the suggestion list if available.

Returns void

showSpinner

Shows the spinner loader.

Returns void

Events

actionBegin

EmitType<Object>

Triggers before fetching data from the remote server.

actionComplete

EmitType<Object>

Triggers after data is fetched successfully from the remote server.

actionFailure

EmitType<Object>

Triggers when the data fetch request from the remote server fails.

beforeOpen

EmitType<Object>

Triggers when the popup before opens.

blur

EmitType<Object>

Triggers when focus moves out from the component.

change

EmitType<ChangeEventArgs>

Triggers when an item in a popup is selected or when the model value is changed by user. Use change event to Configure the Cascading DropDownList

close

EmitType<PopupEventArgs>

Triggers when the popup is closed.

created

EmitType<Object>

Triggers when the component is created.

customValueSpecifier

EmitType<CustomValueSpecifierEventArgs>

Triggers on set a custom value to this component.

dataBound

EmitType<Object>

Triggers when data source is populated in the popup list..

destroyed

EmitType<Object>

Triggers when the component is destroyed.

filtering

EmitType<FilteringEventArgs>

Triggers on typing a character in the component.

focus

EmitType<Object>

Triggers when the component is focused.

open

EmitType<PopupEventArgs>

Triggers when the popup opens.

select

EmitType<SelectEventArgs>

Triggers when an item in the popup is selected by the user either with mouse/tap or with keyboard navigation.