Use the following properties in your displaytag table:
<display:setProperty name="css.tr.even" value="data_even" />
<display:setProperty name="css.tr.odd" value="data_odd" />
Then set up CSS classes to handle even and odd rows. DisplayTag does it for you.
From: Hanen Ben Rhouma [mailto:hanen...@gmail.com]
Sent: Tuesday, February 02, 2010 9:11 AM
To: displaytag-user@lists.sourceforge.net
Subject: [displaytag-user] How to make display tag work with <logic:iterate>
and <logic:equal>
Hello there,
Please I've got an issue using display taglib with <logic:iterate>
<logic:equal> struts taglibs.
In fact, all I want to do is getting the sortable table columns in the same
time with colored rows (the color is decided with one parameter "type" value
which represents one of the columns).
Without that sorting option I used to make advantage of <logic:iterate> and
<logic:equal> same as this example:
<table>
<thead>
<%-- set the header --%>
<tr align="center" bgcolor="#999900">
<th><b>Type</b></th>
<th><b>Description</b></th>
<th><b>Change Number</b></th>
<th><b>Date</b></th>
<th><b>User</b></th>
</tr>
</thead>
<tbody>
<%-- start with an iterate over the collection changes --%>
<logic:iterate name="changeListForm" property="changes" id="change">
<logic:equal name="change" property="shortType" value="DE">
<tr bgcolor="#99CCFF">
<%-- change informations --%>
<td align="center"><bean:write name="change"
property="type" /></td>
<td><bean:write name="change" property="descrip" /></td>
<td align="center"><bean:write name="change"
property="number" /></td>
<td align="center"><bean:write name="change"
property="modtimeString" /></td>
<td align="center"><bean:write name="change"
property="user" /></td>
</tr>
</logic:equal>
</logic:iterate>
</tbody>
</table>
Now, after chosing display tag my table is taking this shape:
<display:table cellspacing="2" cellpadding="1"
style="width: 100%; border: 0; align: center;" name="${stest}"
export="true" id="row" class="dataTable" defaultsort="1"
defaultorder="ascending" pagesize="20"
decorator="org.displaytag.decorator.TotalTableDecorator"
sort="list">
<display:column property="id" title="ID" class="hidden"
headerClass="hidden" media="html" />
<display:column property="type" title="Type" sortable="true"
class="type" headerClass="sortable" />
<display:column property="descrip" title="Description"
sortable="true" group="1" class="description"
headerClass="sortable" />
<display:column property="number" title="Change Number"
sortable="true" group="2" class="number" headerClass="sortable"
/>
<display:column property="modtimeString" title="Date"
sortable="true"
format="{0,date,short}" group="3" class="modtimeString"
headerClass="sortable" />
<display:column property="user" title="User" sortable="true"
class="user" />
</display:table>
Where can I mention my if then else condition to get my colored rows?
Thanks in advance,
Hanen
------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
_______________________________________________
displaytag-user mailing list
displaytag-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/displaytag-user