The javascript is useful for only mouse driven event. However, in my case I need to highlight or set the bgcolor in <td> base on the cell value that is coming back from server.
Any clue? -----Original Message----- From: Matt Raible [mailto:[EMAIL PROTECTED] Sent: Wednesday, October 29, 2003 1:07 PM To: Huang, Andy Cc: [EMAIL PROTECTED] Subject: Re: Information Request for Displaytag You're probably best off addressing these types of questions (or searching) the displaytag-user mailing list (I cc'd them). The homepage for the displaytag is at http://displaytag.sf.net. The easiest way that I've found to do what you're looking for is to use JavaScript. Sort in your question and then set a sorted column indicator with JavaScript. Here's an example: http://tinyurl.com/rbwg And here's a more complete example I've used on my project which sets a sort indicator: <script type="text/javascript"> <!-- var previousClass = null; // simple script for highlighting rows var table = document.getElementsByTagName("table")[0]; var rows = table.getElementsByTagName("tr"); for (i=3; i < rows.length; i++) { rows[i].onmouseover = function() { previousClass=this.className;this.className='tableRowOver' }; rows[i].onmouseout = function() { this.className=previousClass }; rows[i].onclick = function() { var cell = this.getElementsByTagName("td")[0]; var link = cell.firstChild; var href = link.getAttribute("href"); var id = href.substring(href.indexOf("username=")+9, href.length); location.href="<%=request.getContextPath()+editURL.getPath()+"&from=list "%>&username="+id; this.style.cursor="wait"; } } function addSortIndicator() { var table = document.getElementsByTagName("table")[0]; var cols = table.getElementsByTagName("th"); var sort = "<c:out value="${param.sort}"/>"; var order = "<c:out value="${param.order}"/>"; // my own little hack to set the right name for the image if (order == "dec") { order = "desc"; } if (sort == "") { setIndicator(cols[0], "asc"); // 1st column is sorted in query } else { setIndicator(cols[sort], order); } } window.onload=addSortIndicator; function setIndicator(e, order) { e.className = "sorted"; var indicator = document.createElement("img"); indicator.setAttribute("src", "<%=request.getContextPath()%>/images/"+order+".gif"); indicator.setAttribute("width", "9"); indicator.setAttribute("height", "10"); indicator.setAttribute("alt", (order == "asc") ? "Ascending" : "Descending"); indicator.className = "sortIndicator"; e.appendChild(indicator); } //--> </script> Here's a demo of what this sort indicator might look like: http://tinyurl.com/sv54 Hope this helps, Matt On Oct 29, 2003, at 9:05 AM, Huang, Andy wrote: > Hi Matt, > > I have a question about using displaytag. > > One week ago I discovered this displaytag. And I suggest to using it > in our > current project. We have this requirement that the displaytag seem > not able > to handle or it is the case of not flexible enough to make a > modification. > > One requirement is highlighting a given row by a given primary ID. I > can't > seem to use just <logic:equal> in between the table/columns to > identify that > row needed to be highlight. What do you suggest to do here? > > Second requirement is setting the default sorting order for a given > column. > How should I approach this? > > I've been looking at the source for awhile, but don't seem to able to > find > an easy way out. > > Please help! > [EMAIL PROTECTED] ------------------------------------------------------- This SF.net email is sponsored by: SF.net Giveback Program. Does SourceForge.net help you be more productive? Does it help you create better code? SHARE THE LOVE, and help us help YOU! Click Here: http://sourceforge.net/donate/ _______________________________________________ displaytag-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/displaytag-user

