Discussion

1
Replies
2348
Views
Sowmya Lam (SowmyaL2)
Insta Smart

Insta Smart
IN
SowmyaL2 Member since 2018 6 posts
Insta Smart
Posted: May 17, 2019
Last activity: May 17, 2019
Posted: 17 May 2019 6:38 EDT
Last activity: 17 May 2019 8:31 EDT

Control to conditionally change color of label

Hi ,

Hope this would be a helpful post.

Need to change the color of a label conditionally using a control.

I have a grid that displays the status of the product ( some data from external system ). The list of the products should be displayed on a table format to the user with the status being disaplyed in different colors based on the status value.

This below snippet can be used as the control to get the colored values.

Control can be a parameterised one to send the property that to be checked in the conditions.

In the below snippet "Property" is the parameter in the control with "smartpromt type" as Rule-Obj-Property.

PFA for details.

<%

String strPropertyName = tools.getParamValue("Property");
String result="";

if (strPropertyName.equals("Test")) {

result = "red";

}
if (strPropertyName.equals("Ariel")) {

result = "green"; }
if(strPropertyName.contains("Basic")){
result = "orange";
}

tools.putParamValue("result" , result);
tools.putParamValue("PropertyValue" , strPropertyName);

%>

<pega:choose>

<pega:when test="param.result=='green'">

<div style="color:green;font-weight:bold">

<pega:reference name="param.PropertyValue" />

</div>

</pega:when>

<pega:when test="param.result=='red'">

<div style="color:red;font-weight:bold">

<pega:reference name="param.PropertyValue" />

</div>

</pega:when>
<pega:when test="param.result=='orange'">

<div style="color:orange;font-weight:bold">

<pega:reference name="param.PropertyValue" />

</div>

</pega:when>

<pega:otherwise/>

</pega:choose>

User Experience Developer Knowledge Share