How to prefill the content of dropdown from a query?

Is it possible to prefill the dropdown from a query?

I have a query and want to fill up the dropdown with the result of the query (unique products in the table)

2 Likes

Is something like this what you're looking for?

Screen Shot 2020-05-18 at 8.30.03 AM

1 Like

You’re the best!. Exactly! Thanks.

1 Like

:bowing_man:

1 Like

@kent This isn't working at all for me :frowning: This is what I see when I reference the query I made. Am I doing something wrong here?

Hi @scottamesmessinger!

Some queries (usualy SQL based ones) return data as an object of arrays like this:
{ key1: [val, val], key2: [val, val] }

Which would make the selection of all of the values in an array easy as shown above, queryName.data.key1.

Many other data sources return an array of objects like this:
[ { key1: val, key2: val }, { key1: val, key2: val } ]

For this, you could either get the array of all of a certain value by using the .map() JS method, or converting it to an object of arrays using our helper function formatDataAsObject() (there’s also the opposite as formatDataAsArray). That would look like either:

queryName.data.map(d=>d.key1)
or
formatDataAsObject(queryName.data).key1

2 Likes

That is wonderful!!! Thanks so much for helping me with that!!!

1 Like

thanks a lot!!!

1 Like