Hello, I am trying to set tag color in tables with JS, but it does not work.
As you can see the JS should result in a proper color, but for some reason it is not displayed
@andrea_bluelabs
For the currentRow.core, is there a value you want to check to see if core == 'something' then make the color of the tag #000000 ?
In the JS section... {{currentRow.core == 'something'?'#000000':'anotherhexvaluehere'}}
OR if it is a value to check within the tags column itself, then {{item == 'somevaluehere'?'#000000':'anotherhexvaluehere' }}
@ScottR currentRow.core is just a JSONB with the string color in it, the property color inside core is an actual color. for example, in this case, core.color is "#000000"
@andrea_bluelabs
in the ID column - try currentRow.core
I created a column named color and set the value of Entry type column cells based on the cell value in the same row:
I think there is a limitation in using the value of the other column as a color value when setting it to a tag using currentRow - when using something like {{item == 'Income'?'#ff4d4d':'#ddf1d9'}} in the JS field for. a tag dropdown it will work.
Oh okay, I see, thank you!
So it is not something I can change. If you are interested I managed to find a solution, I used directly the value of the query return value to calculate the color.
So instead of currentRow.color i use query.data.color[i] and it works.
Hey @andrea_bluelabs and @ScottR! This appears to be a bug on our end (sorry ), so I've linked this thread to the internal bug report and will write back in once fixed. Glad to hear y'all were able to find a workaround in the meantime!
Our team has recently pushed a fix for this! Cloud instances should see mapped colors working properly with tags as of version 2.96.1 and on-prem instances should see it with 2.96.2
Hey @ibrahim! Can you confirm what version of Retool you're seeing this on? You should be able to find it by clicking on the question mark button in the bottom right:
Got it, thanks for letting us know, I'll bring this back to the dev team and continue to pass along updates. In the meantime, you might try adding that column as a regular column using a transformer, in which case JS colors should work. You can try something like:
As of version 2.103.0 the Tag type has been deprecated in custom columns. Existing columns with that type will continue to function, however, you'll notice that you can no longer create new custom columns and set them to the Tag type.
In order to get the functionality you'd otherwise have with a custom column you'll want to use the workaround mentioned above, namely:
To add a custom Tag column, use a Transformer to add an extra column to the Table’s dataset and configure it to be a Tag column.
We're looking to make broader changes soon with the upcoming Table v2 component which has a target of being released in Q1 next year.