#Change color of the buttons

1 messages · Page 1 of 1 (latest)

timber hare
#

Hello,
I want to have the color of the button changed based on value from TableProfiles. Could you tell me why this JS code does not work?
if ({{TableProfiles.selectedRow.verified}}==true) {color:rgb(139,0,139)} else {color:rgb(128,128,128)}

#

Change color of the buttons

hybrid mulchBOT
#

Hi Igor! First of all, you need to enclose the whole JS snippet in double curly
brackets (moustache syntax), not only the variable. Secondly, it does not work
because you used multi-line Javascript. This document should help you on how to
write code in Appsmith:
https://docs.appsmith.com/core-concepts/writing-code#configuring-widgets-with-code
In your particular case, you can use this snippet instead:
{{TableProfiles.selectedRow.verified==true ? 'rgb(139,0,139)' : 'rgb(128,128,128)'}}

Every widget, API & query is exposed as an object which can be used to write logic

timber hare
#

Thanks a lot! It works