Retool mobile map data to generate options

Hi,
I am trying to use my own data to populate automatically an option list select, just as explained in this article.
No problem when doing it for a web app.
However, I can't figure out how to do it for a mobile retool app.
Any help would be welcome!

Hey @loicchabut35!

When using the select component on mobile you can pass in options from your query using {{}} in the "Values" and "Labels" fields:

Both fields expect an array of individual values instead of item objects, so you'll want to format your data accordingly:

The example I'm using is taken from a SQL query, but you may want to use something like {{ formatDataAsObject(yourQuery.data).yourValueColumn }} instead (you can read more about the helper functions here).

Labels are matched with their corresponding values based on index, so in this case since "magenta" and "7" are both first in the array setting a default value of "7" displays the *label *"magenta".

Thank you @Kabirdas for your answer. I don't understand when it might be necessary to use the formatDataAsObject helper function, since you say that the fields expect an array of individual values instead of item objects...

Also, @Kabirdas , I would need to get a list of distinct values : in your example, you have distinct color names, but in my case, I don't have unique entries.

I found the answer here, it's all good!

Glad you found an answer @loicchabut35!

If you're using SQL there's no need to use formatDataAsObject. The helper function is just to get that specific syntax to work for folks whose yourQuery.data might be formatted differently.

1 Like