Discussion
Salame
Last activity: 19 May 2022 6:49 EDT
Color coding based on a condition
Hello Guys,
I need to change the color of a control based on a defined condition (e.g. make the background-color: red if its value = "X" ). How to do that?
Thanks a lot,
Rosy
-
Like (0)
-
Share this page Facebook Twitter LinkedIn Email Copying... Copied!
Updated: 27 Apr 2022 16:38 EDT
Pegasystems Inc.
IN
- would creating two layouts with desired format applied with visible when works?
- applying the when rule at inline css style
- <pega:when name="<when rule validating the value>">background-color: red;</pega:when> works? please share your observations, Thank you!
- also please refer OOTB RULE-HTML-SECTION ASSIGN- PXURGENCYASSIGN
Updated: 27 Apr 2022 16:38 EDT
Salame
Thanks Phani, I will try it and get back to you!
Thanks a lot,
Rosy
Updated: 27 Apr 2022 16:38 EDT
Pegasystems Inc.
US
Rosy,
If I recall correctly Nathan Harmon was able to do that within Pega Marketing. Hopefully he sees this and remembers the details, if I recall it involved the conditional invocation of skin rules from the presentation tab.
Matt
Updated: 27 Apr 2022 16:38 EDT
Salame
Thanks Mathew, I will be waiting for Nathan's answer!
Thx,
Rosy
Updated: 27 Apr 2022 16:38 EDT
Pegasystems Inc.
US
Hi Rosy,
There are already some good responses here from Phani and David. Generally when we've needed to do this in Pega Marketing, we will approach this as they both suggested: two (or more, depending on use case) controls with the various relevant styling applied, and then mutually exclusive visibility conditions applied. The styling could be set up any number of ways - skin styles, custom CSS which you have access to, or (as a last resort, since it will generate a maintainability warning) inline CSS.
The other thing to note is that for the control to appear to update dynamically (for instance, if the styling is dependent on the value of the control after the user enters it), the control would have to post the value on change, and the containing layout should have a refresh condition checking for when that value changes. (Alternatively, if you'd like to prevent a full layout refresh and limit it to just your group of controls, each control can have "run visibility condition on client" selected).
Hope this helps!
Updated: 27 Apr 2022 16:38 EDT
The way I've seen this is done before is to have multiple instances of the control, each styled differently, then conditionally show/hide each one based on your condition.
Updated: 27 Apr 2022 16:38 EDT
Pegasystems Inc.
IN
Updated: 27 Apr 2022 16:38 EDT
Salame
Thanks a lot Phani!
Updated: 27 Apr 2022 16:38 EDT
Asurion
US
Any update on the enhancement request, do we know if any such provision is added OOTB in next versions of Pega.
Updated: 27 Apr 2022 16:38 EDT
Pegasystems Inc.
IN
Hi Pavan,
I have added the enhancement ID under the Related Support Case Number field in the original post above. Please refer this to ask your Pega Account Executive for any updates on the enhancement.
-
Bhaskar Gopasani
Ordina
NL
@RosyS608 Actually, there is another option aswell: set the style in a pre data transform based on when conditions so that you only need to refer to a property once. This is currently not working in non-optimized tables and there could be some CSS overriding this aswell, but we have a working implementation of this in other cases. @RosyS608
-
KASIM ERGUN