AutoComplete
AutoComplete
Learn how to use AutoComplete input type for searching and selecting from large datasets with real-time filtering. AutoComplete provides a better user experience than dropdowns when dealing with large lists of options.
A comprehensive guide for using AutoComplete in form configurations. This guide covers how to configure AutoComplete inputs with remote data, local options, filtering, and custom configurations.
Overview
The FormInputType.autocomplete allows you to:
Search large datasets - Efficiently search through hundreds or thousands of options
Real-time filtering - Filter options as the user types
Remote data loading - Load options from API endpoints dynamically
Better UX for large lists - Provide a better experience than dropdowns for large option sets
Customizable search behavior - Configure minimum characters, delay, and search parameters
Use Case 1: AutoComplete with Remote Data
Scenario
You have a large list of users and want users to search and select a user efficiently. Instead of loading all users upfront, you want to search them dynamically from the API.
Configuration
Example from Codebase
File: src/app/dashboard/project/services/project.service.ts (lines 82-101)
Parameters Explained
inputType
FormInputType.autocomplete
Specifies AutoComplete input type
β Yes
autoCompleteConfiguration
AutoCompleteConfiguration
Configuration object for AutoComplete. Note: Property name is autoCompleteConfiguration (camelCase), but TypeScript interface is AutoCompleteConfiguration (PascalCase)
β Yes
autoCompleteConfiguration.optionLabel
string
Property name to display in options
β Yes
autoCompleteConfiguration.valueBy
string
Property name to use as value
β Yes
autoCompleteConfiguration.filterBy
string
Property name to filter by
Optional
autoCompleteConfiguration.showClear
boolean
Show clear button
Optional
autoCompleteConfiguration.filter
boolean
Enable filtering
Optional
autoCompleteConfiguration.options
any[]
Array of local options (use with async manualInputsFn)
Optional
autoCompleteConfiguration.remoteDataConfiguration
object
Configuration for remote data loading
Optional
autoCompleteConfiguration.minLength
number
Minimum characters before search
Optional
autoCompleteConfiguration.delay
number
Delay in milliseconds before search
Optional
autoCompleteConfiguration.placeholder
string
Placeholder text
Optional
β οΈ Important Note on Property Name:
In your code, use
autoCompleteConfiguration(camelCase with capital C)The TypeScript interface type is
AutoCompleteConfiguration(PascalCase)This follows TypeScript/JavaScript naming conventions where property names are camelCase and type names are PascalCase
How it Works
User Types: User starts typing in the AutoComplete field
Minimum Length Check: After
minLengthcharacters (e.g., 2), search is triggeredDelay: Waits for
delaymilliseconds (e.g., 300ms) to avoid excessive API callsAPI Call: Makes request to
endPointwith search queryResponse Mapping: Maps API response using
mapHttpResponsefunctionDisplay Options: Shows filtered options matching the search query
Selection: User selects an option, value is set using
valueByproperty
Use Case 2: AutoComplete with Local Options
Scenario
You have a smaller, predefined list of options that you want to load upfront and filter locally.
Configuration
How it Works
Load Options: Options are loaded upfront (synchronously or asynchronously)
Local Filtering: As user types, options are filtered locally
No API Calls: No additional API calls needed during typing
Faster Response: Instant filtering without network delay
Use Case 3: AutoComplete with Custom Search Logic
Scenario
You need custom search logic that searches multiple fields or applies complex filtering.
Configuration
Complete Examples
Example 1: AutoComplete with Local Options Loaded from API (Real Implementation)
This example shows a real implementation from the codebase where users are loaded from API and used in AutoComplete with local filtering.
File: src/app/dashboard/project/services/project.service.ts (lines 82-101)
Result:
Users are loaded from API when form opens
User types "John" β Local filter searches through loaded users
Shows filtered results: "John Doe", "John Smith", etc.
User selects a user β
user_idis set to selected user's ID
Key Points:
Uses
async manualInputsFnto load users before form rendersUses
autoCompleteConfiguration(note the capital C) property nameOptions are loaded once and filtered locally (no API calls while typing)
Better for smaller datasets (< 100 items) where loading all options is acceptable
Example 2: AutoComplete with Local Options
Example 3: AutoComplete with Multiple Fields Display
Comparison Table
Best for
Large datasets (100+ items)
Small datasets (< 50 items)
Search
β Real-time search
β οΈ Filter only (if enabled)
Performance
β Efficient for large lists
β Slow with large lists
User Experience
β Type to search
β οΈ Scroll to find
Remote Data
β Optimized for remote
β Supports remote
Loading
β Lazy loading
β οΈ Loads all options
Best Practices
Use AutoComplete for large lists: When you have more than 50-100 options, AutoComplete provides better UX
Set appropriate minLength: Require at least 2-3 characters before searching to reduce API calls
Add delay for remote searches: Prevent excessive API calls with a delay
Use remoteDataConfiguration for large datasets: Don't load all options upfront
Provide helpful placeholders: Guide users on what to search for
Map API responses properly: Ensure response format matches expected structure
Enable showClear for optional fields: Allow users to easily clear selection
Common Patterns
Pattern 1: Simple Remote AutoComplete
Pattern 2: AutoComplete with Custom Query Params
Pattern 3: AutoComplete with Local Options
Related Documentation
Dropdown Configuration - Learn about dropdown inputs
Async Manual Inputs - Understand async data loading
Form Input Types - See all available input types
Summary
AutoComplete provides an efficient way to search and select from large datasets:
Remote data support: Load options dynamically from API
Real-time filtering: Filter options as user types
Configurable search: Set minimum characters, delay, and search parameters
Better UX: Ideal for large lists (100+ items)
Flexible configuration: Support both remote and local options
This feature enables efficient searching and selection in forms, especially when dealing with large option sets that would be impractical to display in a dropdown.
Last updated