- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2015 08:58 AM
Hello SN community!
I have a UI page that uses some jelly to pull back some records for certain teams and then pops them into a table. See below for a stripped down version of what I am doing essentially.
For example the query starts:
<g:evaluate var="jvar_sd2" object="true">
var gr = new GlideRecord("change_request");
gr.addQuery("active", true);
gr.addQuery('assignment_group','sysidgoeshere');
gr.query();
gr;
</g:evaluate>
Then I draw a table:
<table>
<tr>
<th>CHG</th>
</tr>
<tr>
<td><j:if test="${jvar_sd2.next()}">
${jvar_sd2.getRowCount()}
</j:if></td>
</tr>
</table>
Now the value gets passed into the table but I would like to change the colour of this table cell based on the value in it! For example should this value go higher than 100 then turn it amber, higher than 150 then turn it red etc.
Can you point me in the right direction to do this, am I barking up the wrong tree?
Thanks!
Solved! Go to Solution.
- Labels:
-
User Interface (UI)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2015 09:44 AM
Hi Daniel,
You will need to combine the idea of g:evaluate and JEXL expressions with the HTML class attribute in a manner similar to this:
<style>
.amber {
background-color: <hex color here>
}
.red {
background-color: red;
}
.green {
background-color: green;
}
</style>
<g:evaluate>
var color;
if (<value> > 150) {
color = 'red';
}
else if (<value> > 100) {
color = 'amber';
}
else {
color = 'green';
}
</g:evaluate>
Then in your table, you can apply a dynamic style using JEXL like this:
<td class="${color}"></td>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2015 09:44 AM
Hi Daniel,
You will need to combine the idea of g:evaluate and JEXL expressions with the HTML class attribute in a manner similar to this:
<style>
.amber {
background-color: <hex color here>
}
.red {
background-color: red;
}
.green {
background-color: green;
}
</style>
<g:evaluate>
var color;
if (<value> > 150) {
color = 'red';
}
else if (<value> > 100) {
color = 'amber';
}
else {
color = 'green';
}
</g:evaluate>
Then in your table, you can apply a dynamic style using JEXL like this:
<td class="${color}"></td>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-21-2015 01:50 AM
This works like a dream- thank you Travis!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-13-2018 11:29 PM
Hi Dan,
Could you please send me the full code . I have similar requirement as same.