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"
/>
Examples
Dropdown using Options from a Query
Selected: Sinister Toys
<Dropdown
data={categories}
name=category2
value=category_name
/>
With a Title
Selected: Sinister Toys
<Dropdown
data={categories}
name=category3
value=category_name
title="Select a Category"
defaultValue="Sinister Toys"
/>
With a Default Value
Selected: Odd Equipment
<Dropdown
data={categories}
name=category4
value=category_name
title="Select a Category"
defaultValue="Odd Equipment"
/>
With Hardcoded Options
Selected: 1
<Dropdown name=hardcoded>
<DropdownOption valueLabel="Option One" value="1" />
<DropdownOption valueLabel="Option Two" value="2" />
<DropdownOption valueLabel="Option Three" value="3" />
</Dropdown>
Alternative Labels
Selected: Sinister Toys
This example uses a column called abbrev
, which contains an alternate label for each category
<Dropdown
data={categories}
name=category_abbrev
value=category_name
label=abbrev
/>
Multi-Select
Selected: (SELECT NULL WHERE 0 /* An Input has not been set */)
<Dropdown
data={categories}
name=category_multi
value=category_name
multiple=true
/>
Filtering a Query
Starting with this table of orders:
ID | Order Datetime | Category | Item | Sales |
---|---|---|---|---|
1 | 2020-06-08 | Sinister Toys | Model Racehorse | 12.3 |
2 | 2019-12-11 | Odd Equipment | Microscope | 129.6 |
3 | 2020-12-25 | Sinister Toys | Baseball Card | 3.0 |
4 | 2021-04-27 | Mysterious Apparel | Mystic Pendant | 8.0 |
5 | 2020-03-19 | Cursed Sporting Goods | Running Shoes | 55.0 |
6 | 2021-01-04 | Sinister Toys | Model Racehorse | 13.0 |
7 | 2019-07-08 | Cursed Sporting Goods | Fishing Rod | 89.0 |
8 | 2021-09-19 | Mysterious Apparel | Mystic Pendant | 8.0 |
9 | 2019-11-29 | Cursed Sporting Goods | Fishing Rod | 89.0 |
10 | 2019-12-11 | Odd Equipment | Lamp | 34.0 |
Use this input to filter the results:
Filtered Row Count: 28
ID | Order Datetime | Category | Item | Sales |
---|---|---|---|---|
1 | 2020-06-08 | Sinister Toys | Model Racehorse | 12.3 |
3 | 2020-12-25 | Sinister Toys | Baseball Card | 3.0 |
6 | 2021-01-04 | Sinister Toys | Model Racehorse | 13.0 |
12 | 2020-05-20 | Sinister Toys | Model Racehorse | 13.0 |
16 | 2020-01-05 | Sinister Toys | Model Racehorse | 12.3 |
19 | 2020-11-08 | Sinister Toys | Baseball Card | 3.0 |
20 | 2021-12-11 | Sinister Toys | Model Racehorse | 13.0 |
21 | 2021-08-06 | Sinister Toys | Model Racehorse | 13.0 |
35 | 2020-12-11 | Sinister Toys | Model Racehorse | 12.3 |
37 | 2019-09-22 | Sinister Toys | Model Racehorse | 11.7 |
<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}'
```
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']}
/>
Select all by Default Value with Multiple
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
/>
Select and return all values in the dropdown list, requires "multiple" prop.
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