Select to view content in your preferred language

How to programmatically get value of selected calcite dropdown

1180
2
Jump to solution
12-11-2023 06:03 AM
Danik-B
Occasional Contributor

Just wondering what the best practice for programmatically getting the value of a selected item from a dropdown.  I know I need to listen to the 'onCalciteDropdownSelect' event, then go into 'target' and finally 'selectedItems'.  But from there, what should I use to get the value?

0 Kudos
1 Solution

Accepted Solutions
KittyHurley
Esri Contributor

@Danik-B Thanks for reaching out! Since you mentioned  "onCalciteDropdownSelect", assume you might be using React? If so, you could leverage the useState hook with the Dropdown Item's "label" property/attribute.

Here's an example without a framework to showcase some of what the process could work towards.

View solution in original post

0 Kudos
2 Replies
KittyHurley
Esri Contributor

@Danik-B Thanks for reaching out! Since you mentioned  "onCalciteDropdownSelect", assume you might be using React? If so, you could leverage the useState hook with the Dropdown Item's "label" property/attribute.

Here's an example without a framework to showcase some of what the process could work towards.

0 Kudos
Danik-B
Occasional Contributor

@KittyHurley Thanks for that.  I was using innerText but I like the idea of using label.  Thanks for the solution.

0 Kudos