How to provide distinct values and labels?
See original GitHub issueHello, I retrieve autocomplete data from a remote endpoint and populate results using populateResults
:
accessibleAutocomplete({
element: el,
id: "search_where",
name: "where",
source: debounce(async (query, populateResults) => {
const res = await fetch(`${url}?q=${encodeURIComponent(query)}`);
const data = await res.json();
populateResults(res.results);
}, 100),
});
The res.results
list received is of this form:
{
"q": "pari",
"results": [
{
"id": "75",
"text": "Paris (dƩpartement 75)"
},
{
"id": "75056",
"text": "Paris (75)"
},
// [ā¦]
]
}
I would like to render the text
property value as the option label, but retrieve the id
value when an option is selected by the user (a bit like what is possible using a regular <select>
and <option value="42">Answer</option>
). What data structure should I pass to populateResults
to achieve that, if thatās even possible?
Thanks for your help!
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Excel unique / distinct values: how to find, filter, select and ...
The tutorial demonstrates the most efficient ways to find, filter, select and highlight distinct and unique values in Excel.
Read more >5 easy ways to extract Unique Distinct Values - Get Digital Help
This UDF lets you create and sort a unique distinct list. First you need to copy the VBA code to your workbook, instructions...
Read more >Filter for unique values or remove duplicate values
In Excel, there are several ways to filter for unique valuesāor remove duplicate values: To filter for unique values, click Data > Sort...
Read more >Create CASE WHEN labels based on DISTINCT values in a ...
select id, (case when min(category) = max(category) then min(category) || ' only' when count(distinct category) = 3 then 'All' whenĀ ...
Read more >7 Ways To Generate Unique Values List In Excel
Apply a filter to your data and click the filter arrow to see a list showing all the unique values within that particular...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
My solution in React:
@faithandrel ah, using
templates
is the way to go indeed, totally missed that reading the docs. Thank you for the hint, thatās nicely solving my problem š