Chris Long wrote:
Hello,

I'm attempting to set it up so that each row of my table will have a different background color based on the priority of that row.

My current code looks like this:
[snipped]

and in my CSS file i have a tdboarderred to set it to red for a high priority item, where the priority is an int.

I saw the example that shows something similar to what I'm looking for, however I could not seem to get that to work.

Thanks,

Chris Long


I'm guessing you were looking at this example:

http://displaytag.homeip.net/displaytag-examples-1.1/example-rowclass.jsp

Adding this to your page should add the tdboarder or tdboarderred class attribute to the* <tr>* of each table row.

<% java.util.ArrayList alist = ( java.util.ArrayList)rBean.getReqList();
   request.setAttribute("alist", alist);
%>

*<jsp:scriptlet>
       request.setAttribute("dyndecorator", new 
org.displaytag.decorator.TableDecorator()
       {
           public String addRowClass()
           {
               return ((/YourObject/)getCurrentRowObject()).getPriority() > 4 ? 
"tdboarderred" : "tdboarder";
           }
       });
 </jsp:scriptlet>*



<display:table name="raltable" id="table" width="100%" border="1" name="alist2" scope="request" align="left" requestURI="/requisition/requisition_list.jsf" *decorator="dyndecorator"*> <display:column property="priority" title="Priority" sortable="true" class="tdborder"/> <display:column property="createdBy" title="Started By" sortable="true" class="tdborder"/> <display:column property="spPosition" title="Position" sortable="true" class="tdborder"/>
</display:table>

---

You'll have to make sure that your css is trying to style the correct elements:

tr.boarderred td {
   border: 1px solid #ff0000;
}


will put a border round each cell of a high priority row.

Ed!
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
displaytag-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/displaytag-user

Reply via email to