Jump to content
  • 0

Tabular report - dynamically change text color based on value


rcwb56

Question

I'm new to this.  I have a tabular report of patient's various tests (e.g. [ blood work], [ekg], [ultrasound]) listing the status of the test (e.g. 'Pending', 'Completed'). I'd like to show 'Pending' in color red, 'Completed' in color green.  Is this possible and if so how best to do this? Is it also possible to have these fields have links to individual single record update data pages where the details could be entered

Thanks!

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0
  • 0

Hi,

I use a CASE statement and the code below. The Virtual field is displayed to the user. It uses as it's base input value ([@cbParamVirtual1]) but could also use a table flield as well

You must wrap each THEN stmt using single quotes as the encased HTML uses double quotes. On most datapage types this works (Submission, Edit, Report, and I think Lists <== I haven't tried yet). It consistently works for me and I have had this in production for the last four months.

1.  Define the Virtual field you want to display (give it a Label, ie, Status)

CASE
WHEN [@cbParamVirtual1] < 18.5 THEN '<span style="color:#FFC20E;font-weight:bold;">Underweight</span>'
WHEN [@cbParamVirtual1] BETWEEN 18.5 AND 24.9 THEN '<span style="color:#669900;font-weight:bold;">Healthy Weight</span>'
WHEN [@cbParamVirtual1] BETWEEN 25 AND 29.9 THEN '<span style="color:#FFC000;font-weight:bold;">Overweight</span>'
WHEN [@cbParamVirtual1] BETWEEN 30 AND 34.9 THEN '<span style="color:#ED7D31;font-weight:bold;">Obese</span>'
WHEN [@cbParamVirtual1] > 35 THEN '<span style="color:#C00000;font-weight:bold;">Extremely Obese</span>'
ELSE ''
END

 

To Make it a Link: MUST USE single Quotes to encase THEN part of stmt (this stmt is a POPUP Link and displays an Icon as part of the displayed link. Remove what you don't need

CASE
WHEN [@cbParamVirtual1] < 18.5 THEN '<a class="cbMenuItem" href="#" onclick="window.open(&quot;https://c1hcr495.caspio.com/dp/66ceb000a900a3cc048442e395b7?FoodGroupID=[@field:MyFoodGroup_FoodGroupID]&quot;,&quot;mywindow&quot;, &quot;menubar=1,resizable=1,width=1025,height=600&quot;)"><img alt="" src="[@field:FoodGroup_FoodGroupImage/]" style="width: 35px; height: 35px; margin: 1px;" /></a>'

...

ELSE ''
END

 

I hope this helps.  Let me know if you have any questions.

Lynda

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...