Skip to content

Autocomplete ​

AutocompleteField sets a many-to-one association by typing. Search runs on the server (x-lazy-auto-complete-suggestions). Display and search fields can be paths (assoc1.assoc2.fieldX).

On a form ​

tsx
import { AutocompleteField } from '@chilibase/frontend/autocomplete-field'

<AutocompleteField
  form={this}
  assocField="brandAssoc"
  displayField="name"
  AssocForm={BrandForm}
  SearchBrowse={BrandBrowse}
/>

displayField can be a string or string[] (several columns in the suggestion list).

PropMeaning
assocFieldMany-to-one path (dropdown/autocomplete runs on the last assoc)
displayFieldField(s) shown and searched
AssocForm / assocFormElementInsert / edit the selected row in a form
SearchBrowse / searchBrowseElementOpen a browse to pick a row
suggestionsLoadHow suggestions are loaded (lazy is the usual DB search)
lazyLoadMaxRowsCap for lazy load
minLengthCharacters before search (default 1)
filterExtra CustomFilter, or (entityRow) => CustomFilter
sortFieldSort of suggestions
fieldsExtra associations to fetch with suggestions
dropdownButtonEnabledShow the dropdown button (default true)

There is also AutocompleteInput (no form binding) and TableAutocompleteField / AutocompleteColumn for DetailDataTable.

In a browse filter ​

On LazyDataTable, set autoComplete on a Column (true infers the field, or pass an options object) so the column filter uses autocomplete instead of a plain input.

Search field ​

If you prefer a button that opens a browse (no typeahead), use SearchField (@chilibase/frontend/search-field) with a browse that forwards searchBrowseParams.

Released under the MIT License.