I have a colum that shows an integer from 1-5.
In table view I would like to show the cell background based on the value of the cell.
E.g.
If the value is 1, then 1 is presented with a blue cell background.
If the value is 2, then 2 is presented with a red cell background.
I guess I can do this by adding some javascript to my table TV template, but would really appreciate some hints in the right direction.
Thanks a lot.
Conditional colouring
Re: Conditional colouring
I managed to solve this one by myself eventually...
For any other interested parties:
In this case my colum is called 'b'.
Edit /templates/myapp_templateTV.html
Find
Replace with:
For any other interested parties:
In this case my colum is called 'b'.
Edit /templates/myapp_templateTV.html
Find
Code: Select all
<td id="myapp-b-<%%VALUE(id)%%>" class="myapp-b text-center"><%%VALUE(b)%%></td>
Code: Select all
<td id="myapp-b-<%%VALUE(id)%%>" class="myapp-b text-center"><script>
if ('<%%VALUE(b)%%>' == 1){document.write('<div style="background-color:#00FF00;font-weight: bold"><%%VALUE(b)%%></div>');}
else if ('<%%VALUE(b)%%>' == 2){document.write('<div style="background-color:#008000;font-weight: bold"><%%VALUE(b)%%></div>');}
else if ('<%%VALUE(b)%%>' == 3){document.write('<div style="background-color:#FFFF00;font-weight: bold"><%%VALUE(b)%%></div>');}
else if ('<%%VALUE(b)%%>' == 4){document.write('<div style="background-color:#FF8000;font-weight: bold"><%%VALUE(b)%%></div>');}
else if ('<%%VALUE(b)%%>' == 5){document.write('<div style="background-color:#FF0000;font-weight: bold"><%%VALUE(b)%%></div>');}
else {document.write('<div><%%VALUE(b)%%></div>');}
</script> </td>