SparkViewEngine: Highlight Table Alt Row

Posted in aspmvc on March 29th, 2010 by taswar

Here is how one highlights an alt row with spark, quite clean I tell you.
Assuming you have a css that like below.

1
2
3
4
5
6
tr.alt {
    text-align: left;
    padding: 2px;
    border: 1px solid #000;
    background:	#ADDFFF;
}

And in your template you will call it like this.

?View Code CSHARP
1
2
3
4
5
6
7
8
9
10
11
12
13
14
<table>
<tr>
	<th>ID</th>
	<th>FirstName</th>
	<th>LastName</th>
	<th>Gender</th>
</tr>
<tr each="var person in people" class="alt?{personIndex % 2 == 0}">
	<td>${person.Id}</td>
	<td>${person.FirstName}</td>
	<td>${person.LastName}</td>
	<td>${person.Gender}</td>	
</tr>
</table>

Note: How I am using personIndex. It basically goes with the item, thus if you have var order in Orders, you would then say orderIndex

Share

Leave a Comment