LogoLogo
  • Adapptio User Documentation
  • Getting Started
    • Quickstart
    • Architecture Overview
      • Views
      • Actions
      • Integrations
      • API Endpoints
      • Routes
      • Events
      • Assets
    • Editor
      • Main Menu
        • Create New Resources
        • Manage the Application
        • Monitoring Errors
      • Main Toolbar
        • Deploying the Application
        • Opening the Application
        • Preview Mode
        • Error Monitor
      • Components Panel
        • Components
        • Inspector
        • View Settings
      • Outline Panel
        • Data Variables
          • State Variable
          • Data From Action
      • Data Explorer
      • Console
    • Playground
  • Working with Adapptio
    • Best Practices
    • Tutorials
      • 1. Hello World
      • 2. Visualize Data from API
      • 3. Advanced Layout Application
      • 4. Application with In-Memory Database
    • How To
      • Custom Auth
      • Action Logic
        • Transform Node
      • UI Logic
        • Logout
        • Conditional Render
        • One Of
      • Data & Dynamic values
        • Custom Variable
        • Data from Action
        • Dynamic Value
        • Change Value from Event
        • Loading Data from Action to Form
        • Sending Data to Action from a Form
        • Server-side Dropdown Autocompletion
      • Visual
        • Styling Icon Button
      • Layouts
        • Centered Box
        • Header & Sidebar Layout
        • Grid Form Layout
        • Stretched Layout in Row
    • Components
      • Composed Chart
      • Advanced Table
      • Custom Component
    • Examples of Applications
      • SaaS Platforms
      • Customers Portals
      • Information Systems
      • Internal Tools
        • Color Picker
      • IoT Applications
      • Smart Portals
      • Analytics & Calculators
      • Statistics & Monitoring Panels
      • API Data Visualization
      • Simple Games
  • DEPLOYMENT
    • Cloud Hosted
    • Self Hosted
  • REFERENCE GUIDE
    • Components List
      • Application Header
      • Box
      • Container
      • Grid
      • Sidebar Layout
      • View
      • Text Input
      • Number
      • Checkbox
      • Option
      • Date and Time
      • File Upload
    • Properties
      • ACCEPT
      • CUSTOM PLACEHOLDER
      • DESCRIPTION
      • ENABLED
      • FONT SIZE
      • FOREGROUND COLOR
      • FORM DATA KEY
      • HEADERS
      • ICON
      • ID
      • LABEL
      • METHOD
      • MULTIPLE
      • MAX FILE SIZE
      • REQUEST TIMEOUT
      • REQUIRED
      • READ-ONLY
      • SIZE
      • TEXT ALIGNMENT
      • TEXT STYLE
      • URL
      • UPLOAD IMMEDIATELY
      • VALIDATE
      • VALUE
    • Functions
      • Array
      • Date
      • Generators
      • JSON
      • Logic
      • Math
      • Object
      • String
      • Types
      • Util
  • Support
    • Get in touch
    • Release Notes
  • Legal
    • Terms and Conditions
    • GDPR
Powered by GitBook
On this page
  • 1. Create Action
  • 2. Add Options Component
  • 3. Add Data Source
  • 4. Link Completion Items to Options Component
  • 5. Test It

Was this helpful?

  1. Working with Adapptio
  2. How To
  3. Data & Dynamic values

Server-side Dropdown Autocompletion

You can

You can configure the Options component to load items dynamically based on user value (search).

To do that, you need to prepare an Action with a search parameter that will return filtered items. Then you need to add that action as a Data Source into your view. And finally, you have to link the data source with your Options component and configure it properly. Let's do a quick example.

TL;DR - Quick steps

1. Create Action

Let's create an action called GetCompletionItems. It will have a search parameter of type String and one Transform Node with the following JavaScript code. Data returned from this transform node are directly compatible with the Options component's property items.

In a real case, you will have to set up the action in a way that matches your needs, this is just an example.

const createItem = (value, label) => ({
  value: value,
  labelText: {
    value: label
  }
});

const items = [
  createItem("testA", "Test A"),
  createItem("testB", "Test B"),
  createItem("testC", "Test C"),
  createItem("anotherTestA", "Another Test A"),
  createItem("anotherTestB", "Another Test B"),
  createItem("anotherTestC", "Another Test C")
];

if ($.params.search) {
  return items.filter((x) => {
    return x.labelText.value.includes($.params.search);
  });
} else {
  return items;
}

The action will look like this:

You can Run the action to verify it works correctly.

2. Add Options Component

Next, let's add an Options component to your View and configure it as follows.

3. Add Data Source

Now, in your view, add Data from action and in the inspector, select the action you've created in the first step - GetCompletionItems.

Change the data source ID to completionItems.

Then link the search parameter to the customValue property of the Options component. To do that, set the search parameter to fx and enter the following expression.

optionsField.customValue

The customValue property contains a text a user enters during the search. So when the user is searching, this expression will update the action parameter, and new completion items will be loaded.

4. Link Completion Items to Options Component

The final step is to link data from the action to the Options component's items.

Select the Options component and configure the Items property to fx, and enter the expression:

completionItems.data

5. Test It

Then switch to the Preview mode and click on the Options component. You should see all the items, and when you start typing into the search field, only the matching items should be visible.

PreviousSending Data to Action from a FormNextVisual

Last updated 2 years ago

Was this helpful?