# Autocomplete cell type
autocomplete cell type enables the user to choose a suggested option while typing. Autocomplete can be configured in three different ways, lazy mode, strict mode, and strict mode using Ajax.
# Autocomplete lazy mode
This example uses the
autocomplete feature in the default lazy mode. In this mode, the user can choose one of the suggested options while typing or enter a custom value that is not included in the suggestions.
In this mode, the mouse and keyboard bindings are identical to the Handsontable cell type. The options are rendered from the
source property, either an array or a function that returns an array.
# Autocomplete strict mode
This is the same example as above, the difference being that
autocomplete now runs in strict mode. In this mode, the autocomplete cells will only accept values that are defined in the source array. The mouse and keyboard bindings are identical to the Handsontable cell type but with the differences below:
- If there is at least one option visible, there always is a selection in HOT-in-HOT
- When the first row is selected, pressing ARROW UP does not deselect HOT-in-HOT. Instead, it behaves as the ENTER key but moves the selection in the main HOT upwards
In strict mode, the allowInvalid option determines the behaviour in the case of manual user input:
allowInvalid: trueoptional - allows manual input of a value that does not exist in the
source, the field background is highlighted in red, and the selection advances to the next cell
allowInvalid: false- does not allow manual input of a value that does not exist in the
source, the ENTER key is ignored, and the editor field remains open
# Autocomplete strict mode (Ajax)
Autocomplete can also be used with Ajax data sources. In the example below, suggestions for the "Car" column are loaded from the server. To load data from a remote asynchronous source, assign a function to the 'source' property. The function should perform the server-side request and call the callback function when the result is available.