Jump to content

Conditionally Change Background Color of a Field based on List String Field Content


Recommended Posts

I have a Tabular Data Report that contains several information, and a column with status. This Status is a List String that the user can also use to order the rows, or even as a filter in the search form. The point is that i tried to apply some conditionally changes using the tips in the caspio website and also using some content here of the forum, but with no success, and i'm almost certainly that is because i don't know javascript well. So, in the list string of status have some options to be selected, but i would like that if i select one of the options and update the row, the color of the row change based on the option i have selected. In example: If i change the status of "Day 1: Entry of Order" to "Day 4: Order Delay", the row that was with a normal backgroud before the update, with the new status selected, turns on red. I expect that my example could be clear enough to compreend the problem, and if need, i can send the link via message box for you to have a better idea of the problem.

Link to post
Share on other sites

List string can have more than one option selected , so you can use the code below in an HTML Block that is added to the end of element list in your report page

 

<a id="visi[@field:Id#]"> 
<script>
var isi = document.getElementById("visi[@field:Id#]");
var str='[@field:ListString]';
if(str.includes("Day 1: Entry of Order")){

isi.parentNode.parentNode.style.backgroundColor = 'red';
}

else if(str.includes("Day 4: Order Delay")){

isi.parentNode.parentNode.style.backgroundColor = 'yellow';
}


</script></a>

Replace [@field:Id#] and [@field:ListString] and select them from picker. ID should be the unique field in your table. 

Link to post
Share on other sites
  • 2 months later...

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
Reply to this topic...

×   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...