
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2018 04:52 AM
I don't find the solution to retreive a number of line as record to calculate to know if this is odd or even.
if even, set the green in color of record , if no, gray in color of record.
Because, I would like to appear the alternating color of line in a table.
there is my script, see below. May you help it please ?. Thank you in advance for your return
-----
<g2:evaluate var="jvar_inc">
var inc = new GlideRecord('incident');
var color;
inc.addActiveQuery();
inc.addQuery('priority',1);
//** here : how to retreive a number of line as record ? **//
//** ROW as a number of line **//
var row = inc.getRowNumber();
row;
if(row % 2 == 0){
Color = "even";
}else{
Color= "odd";
}
inc.setCategory('homepage');
inc.query();
</g2:evaluate>
<style>
.odd{background-color: white;}
.even{background-color: gray;}
</style>
<table class="fixed_header" >
<tbody >
<j2:while test="$[inc.next()]">
<j2:set var="jvar_inc_link" value="incident.do?sys_id=$[inc.sys_id]"/>
<j2:set var="jvar_inc_list_link" value="incident_list.do?sysparm_query=active=true"/>
<tr class="${color}">
<td ....</td>
</tr>
</j2:while>
</tbody>
</table>
----
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-13-2018 02:23 AM
you may want to add a unique style class name to the your table and wrap the above CSS with the parent table style class.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-10-2018 10:23 AM
way easier than what i suggested!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-12-2018 06:29 AM
I fall into the water on 1 problem:
- the appearance of the color in the background of the dashboard .see the screenshot below.
I was looking for a solution to keep colors alternately in the widget and no, in the background of the dashboard ... not successful! ...
Can you help how to do it? here is my script, below.
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<g:evaluate var="jvar_inc" jelly="true" object="true">
var i=0;
var Col1 =new Array(0);
var colcolor =new Array(0);
var inc = new GlideRecord('incident');
inc.addActiveQuery();
inc.addQuery('priority',3);
inc.setCategory('homepage');
inc.setLimit(10);
inc.query();
</g:evaluate>
<style>
tr:nth-child(even) {background: #FCCAC9}
tr:nth-child(odd) {background: yellow-light}
</style>
<frame>
<div>
<table cellspacing="2" cellpadding ="4" border="2" width="60%">
<thead bgcolor="#E9967A">
<tr>
<th width="15%"><center>Number</center> </th>
<th width="10%"><center>Priority</center> </th>
<th width="20%"><center>State</center> </th>
<th width="100%"><center>Description</center> </th>
</tr>
</thead>
</table>
</div>
<div>
<g2:scrollable_area height="175px">
<table cellspacing="2" cellpadding ="4" border="2" width="60%">
<tbody>
<j2:while test="$[inc.next()]">
<j2:set var="jvar_inc_link" value="incident.do?sys_id=$[inc.sys_id]"/>
<j2:set var="jvar_inc_list_link" value="incident_list.do?sysparm_query=active=true"/>
<tr >
<td width="15%"><center> $[inc.number]</center> </td>
<td width="10%"><center> $[inc.priority]</center> </td>
<td width="20%"><center> $[inc.state.getDisplayValue()]</center> </td>
<td width="100%" >$[inc.short_description]</td>
</tr>
</j2:while>
</tbody>
</table>
</g2:scrollable_area>
</div>
<div>
<table>
<tr>
<td align="center" colspan="2"><a href="$[jvar_inc_list_link]" class="linked">${gs.getMessage("View all active Incidents")}</a></td>
</tr>
</table>
</div>
</frame>
</j:jelly>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-13-2018 02:23 AM
you may want to add a unique style class name to the your table and wrap the above CSS with the parent table style class.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-13-2018 06:12 AM
Finally, it works !... I didn' understand why ... and I has a migraine !.... 😉
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-13-2018 06:51 AM
Happy to help. Always.