Dropdown
Creates a dropdown menu with a list of options that can be selected. The selected option can be used to filter queries or in markdown.
To see how to filter a query using a dropdown, see Filters.
Selected: Sinister Toys
<Dropdown
data={categories}
name=category1
value=category_name
title="Select a Category"
defaultValue="Sinister Toys"
/>
Selected: {inputs.category1.value}
Examples
Dropdown using Options from a Query
<Dropdown
data={categories}
name=category2
value=category_name
/>
Selected: Sinister Toys
With a Title
<Dropdown
data={categories}
name=category3
value=category_name
title="Select a Category"
defaultValue="Sinister Toys"
/>
Selected: {inputs.category3.value}
With a Default Value
Selected: Odd Equipment
<Dropdown
data={categories}
name=category4
value=category_name
title="Select a Category"
defaultValue="Odd Equipment"
/>
Selected: {inputs.category4.value}
With Hardcoded Options
<Dropdown name=hardcoded>
<DropdownOption valueLabel="Option One" value="1" />
<DropdownOption valueLabel="Option Two" value="2" />
<DropdownOption valueLabel="Option Three" value="3" />
</Dropdown>
Selected: {inputs.hardcoded.value}
Alternative Labels
This example uses a column called abbrev
, which contains an alternate label for each category
Selected: Sinister Toys
<Dropdown
data={categories}
name=category_abbrev
value=category_name
label=abbrev
/>
Selected: Sinister Toys
Multi-Select
<Dropdown
data={categories}
name=category_multi
value=category_name
multiple=true
/>
Selected: {inputs.category_multi.value}
Filtering a Query
Starting with this table of orders:
```sql order_history
select id, order_datetime, category, item, sales from needful_things.orders
limit 100
```
<DataTable data={order_history}/>
Use this input to filter the results:
Filtered Row Count: 28
<Dropdown
data={query_name}
name=name_of_dropdown
value=column_name
/>
```sql filtered_query
select *
from source_name.table
where column_name like '${inputs.name_of_dropdown.value}'
```
Filtered Row Count: {orders_filtered.length}
<DataTable data={orders_filtered}/>
Multiple defaultValues
Selected: ('Mysterious Apparel','Sinister Toys')
<Dropdown
data={query_name}
name=name_of_dropdown
value=column_name
multiple=true
defaultValue={['Sinister Toys', 'Mysterious Apparel']}
/>
Selected: {inputs.category_multi_default.value}
Select all by Default Value with Multiple
Select and return all values in the dropdown list, requires "multiple" prop.
Selected: ('Cursed Sporting Goods','Mysterious Apparel','Odd Equipment','Sinister Toys')
<Dropdown
data={categories}
name=category_multi_selectAllByDefault
value=category_name
title="Select a Category"
multiple=true
selectAllByDefault=true
/>
Selected: {inputs.category_multi_selectAllByDefault.value}
Dropdown
Options
- Options:
- query name
- Options:
- column name
- Options:
- value from dropdown | array of values e.g. {['Value 1', 'Value 2']}
- Options:
- boolean
- Default:
- false
- Options:
- boolean
- Default:
- false
- Options:
- column name
- Default:
- Uses the column in value
- Options:
- string
- Options:
- column name [ asc | desc ]
- Default:
- Ascending based on dropdown value (or label, if specified)
- Options:
- SQL where clause
DropdownOption
Options
The DropdownOption component can be used to manually add options to a dropdown. This is useful to add a default option, or to add options that are not in a query.
- Default:
- Uses the value