object-dropdown
Version compatibility
object-dropdown
is supported in all versions of the JourneyApps Container and Runtime.- It received several functional updates in version 4.84.0 of the JourneyApps Runtime, including the ability to bind to an array, which allows a user to select multiple options.
The
object-dropdown
UI component lists objects from a database query or array for selection by the user. Once an object, or multiple objects (since runtime version 4.84.0) are selected, they can be stored as a field, or used to further your app's workflow.main.view.xml
<var name="countries" type="query:country" />
<!-- OR -->
<var name="countries" type="array:country" />
<var name="selected_country" type="country" />
<object-dropdown label="Country of residence" query="countries" bind="selected_country" required="false" />
main.js
function init() {
view.countries = DB.country.all();
// OR
view.countries = DB.country.all().toArray();
}
main.view.xml
<var name="countries" type="query:country" />
<!-- OR -->
<var name="countries" type="array:country" />
<var name="selected_countries" type="array:country" />
<object-dropdown label="Country of residence" query="countries" bind="selected_countries" required="false" />
main.js
function init() {
view.countries = DB.country.all();
// OR
view.countries = DB.country.all().toArray();
}
A selected option in the
object-dropdown
component:
List of options in the
object-dropdown
component:
Note
By default, when 12 or more options are listed in an
object-dropdown
a search box appears at the top of the list of options. It can be used to more efficiently find an option. See the search-controls reference for more information.Example - bind to a single object:
main.view.xml
<var name="countries" type="query:country" />
<var name="selected_country" type="country" />
<object-dropdown label="Country of residence" placeholder="Select a country" query="countries" bind="selected_country" required="false" />

Version compatibility
Binding an
object-dropdown
to an array was introduced in version 4.84.0 of the JourneyApps Runtime.main.view.xml
<var name="countries" type="query:country" />
<var name="selected_countries" type="array:country" />
<object-dropdown label="Previous countries of residence" placeholder="Select all that apply" query="countries" bind="selected_countries" required="false" />

Required
Default: unset
query
contains the name of the database query or array variable to populate the objects in the object-dropdown
.<var name="countries" type="query:country" />
<!-- OR -->
<var name="countries" type="array:country" />
<object-dropdown query="countries" bind="selected_country" required="false" />
Version compatibility
align-content
was introduced in version 4.84.0 of the JourneyApps Runtime.Optional
Type:
center
| left
| right
Default:
center
Version compatibility
align-dialog-content
was introduced in version 4.84.0 of the JourneyApps Runtime.Specifies how the content of the list of options dialog should be aligned. This includes the display value of each option, as well as the header text of the dialog.
<object-dropdown label="Country of residence" align-dialog-content="left" query="countries" bind="selected_country" />
Optional
Type:
string
Default: "Choose an option"
Version compatibility
dialog-title
was introduced in version 4.84.0 of the JourneyApps Runtime.Header text of the dialog that displays the list of options of the
object-dropdown
.<object-dropdown label="Country of residence" dialog-title="Choose the country of residence" query="countries" bind="selected_country" />
Optional
Type:
string
Default: The
<display/>
tag of the object as defined in the app's data modelSpecifies the display value of each option in the
object-dropdown
list. Can be a static string, a format string or a JS/TS function.schema.xml
<model name="country" label="Country">
<field name="name" label="Name" type="text:name"/>
<field name="population" label="Population" type="integer"/>
<display>{name}</display>
</model>
main.view.xml
<!-- Here the display value for each option is the country's name and population, separated by a "-" -->
<object-dropdown label="Country of residence" display="{name} - {population}" query="countries" bind="selected_country" required="true" />
Version compatibility
empty-message
was introduced in version 4.84.0 of the JourneyApps Runtime.Optional
Default: unset
Text that is displayed if no options are available to list once the user opens the
object-dropdown
.Version compatibility
icon-position
was introduced in version 4.86.1 of the JourneyApps Runtime.Version compatibility
label-case
was introduced in version 4.84.0 of the JourneyApps Runtime.Version compatibility
modifier-text
was introduced in version 4.84.0 of the JourneyApps RunOptional
Type:
auto
| none
| show
Default:
auto
Version compatibility
search-controls
was introduced in version 4.84.0 of the JourneyApps Runtime.
Set the visibility of the search box of the
object-dropdown
component. auto
shows the search box when the list of options contains 12 options or more. none
never shows the search box, and show
always shows the search box at the top of the list of options.<object-dropdown label="Country of residence" query="countries" bind="selected_country" search-controls="show" />
The following component methods are available when an
id
is assigned to the component and component.objectDropdown({id:'my-id'})
is called from JS/TS:Programmatically clear the selected value(s) bound to the
object-dropdown
.Programmatically clear a value entered into the search box.
Programmatically open the list of items.
Programmatically close the list of items.
Programmatically scroll down the list of items when the
object-dropdown
is opened.Programmatically scroll until the
object-dropdown
is visible in the view.Programmatically scroll up the list of items when the
object-dropdown
is opened.Programmatically select an item from the list by its display value.
main.view.xml
<var name="countries" type="query:country" />
<var name="selected_country" type="country" />
<object-dropdown id="my-dropdown" query="countries" bind="selected_country" label="Country" />
main.js
function select() {
component.objectDropdown({id: 'my-dropdown'}).openDropdown(); // Need to open the dropdown first
component.objectDropdown({id: 'my-dropdown'}).selectItem("Germany");
}
Programmatically select an item from the list by its index. Note: Indexes begin at 1.
main.view.xml
<var name="countries" type="query:country" />
<var name="selected_country" type="country" />
<object-dropdown id="my-dropdown" query="countries" bind="selected_country" label="Country" />
main.js
function select() {
component.objectDropdown({id: 'my-dropdown'}).openDropdown(); // Need to open the dropdown first
component.objectDropdown({id: 'my-dropdown'}).selectItemByIndex(2);
// Selects the second country in the list
}
Programmatically enter a search value and triggers a search of the
object-dropdown
.Last modified 1mo ago