Retool Database Enums into table component as Tags

Hello!

I'm have a bunch of ENUM columns set in a retool database. I am able to set the Tag colors in that database, but when bringing these into the table component, the colors are set randomly.

If I turn automatically assign tag colors to unticked, they just turn grey, but it's not clear where I should then set the tag colors again?

In addition.. i'm pulling the mapped option list using the below query. is it possible to pull the colors set in the retool database using this query?

SELECT
  enum.enumsortorder,
  type.typname,
  enum.enumlabel AS value
FROM pg_enum AS enum
JOIN pg_type AS type
  ON (type.oid = enum.enumtypid)
WHERE type.typname like 'producer%'
GROUP BY enum.enumsortorder,
         enum.enumlabel,
         type.typname

ORDER BY enumsortorder

Any help appreciated!

many thanks ,

Hey there @ChrisPEL ,

Here are a couple of posts that can guide you on how to set up your tag colors. You are using an option list, not sure if mapped or manual, but that's where you can define the color for each tag:

Manual option list:

Mapped option list:

1 Like

Thanks for this! I'm using a mapped option. is there a way to pull the color that is defined in the retool database enum list using an additional elements in the enum query i have already? Ideally i don't want to transform and do this manually, as any items added to the enum list would need to be updated in every transformer i use as well..

Thanks!

Yes, it should be definitely possible.

Not sure I completely understand your data structure, but any value you get in your query (which you then use as data source for your mapped options) can be referred to by using item, e.g. item.typname

Thank you. To clarify, i'm using the built in Retool Database, where its possible to set colors to ENUM list options when defining an ENUM column in a table. Ideally i would want to pull those preset colors through when i query for the ENUM options, but i'm not sure how to go about doing that, and cannot find any documentation about it.

Hi @ChrisPEL,

Interesting question, I haven't used enums in Retool Database but I see that there is a color pallet :sweat_smile:

I also can't seem to figure out how to grab the color which corresponds to the enum option.

Let me double check with our backend engineering team to see if they have can help!

How many colors are you working with in total? A temporary workaround in the short term would be to use a Variable in the app where the key is the ENUM option and the value would be hard coded names of the colors. Thus you could grab the enum options and then style the frontend component/table cell to match the color value returned when keying in with the item.enumOption as Miguel mentioned :thinking:

1 Like