The following comment has been added to this issue:
Author:
Created: Tue, 16 Nov 2004 10:58 PM
Body:
I have done a similar thing as above but expanded on it. You can only highlight
one row. We wanted to do that coz we only we wanted to apply some kind of
action to that row only.
/**
* This JavaScript performs the task of highlighting a row in a displayTag
table.
* The javascript is called by adding the following line in your JSP page after
the
* declaration of your display tag
* <script type="text/javascript">highlightTableRows("searchResultTO");</script>
* An example is as follows:
* <html>
* <body>
* <displaytag:table
name="${sessionScope.searchResultList}" id="searchResultTO"/>
* <script
type="text/javascript">highlightTableRows("searchResultTO");</script>
* </body>
* </html>
*/
/**
* This function after the displayTag table has been created adds a onclick
event
* handler to each row in the table. The onclick event will first reset all
rows to
* the default background color which is white and then assign the clicked row
to the
* highlight color which is a light green.
*/
function highlightTableRows(tableId) {
var previousClass = '';
var table = document.getElementById(tableId);
var tbody = table.getElementsByTagName("tbody")[0];
var rows = tbody.getElementsByTagName("tr");
// add event handlers so rows light up and are clickable
for (i=0; i < rows.length; i++) {
rows[i].onmouseover = function() {
this.style.cursor="hand";
};
rows[i].onmouseout = function() {
this.style.cursor='';
};
rows[i].onclick = function() {
//reset all styles to blank for all rows
resetStylesAroundRow(this);
this.style.backgroundColor = "#74BAB7";
var cell = this.getElementsByTagName("td")[0];
if (cell.getElementsByTagName("a").length > 0) {
var link = cell.getElementsByTagName("a")[0];
if (link.onclick) {
call = link.getAttributeValue("onclick");
// this will not work for links with onclick handlers that
return false
eval(call);
} else {
location.href = link.getAttribute("href");
}
this.style.cursor="wait";
}
};
}
}
/**
* Resets the table rows back to the default color.
*/
function resetStylesAroundRow(row) {
var previousClass = '';
var table = row.parentElement.parentElement;
var tbody = table.getElementsByTagName("tbody")[0];
var rows = tbody.getElementsByTagName("tr");
for (i=0; i < rows.length; i++) {
rows[i].style.backgroundColor = "white";
}
}
---------------------------------------------------------------------
View this comment:
http://jira.codehaus.org/browse/DISPL-92?page=comments#action_26502
---------------------------------------------------------------------
View the issue:
http://jira.codehaus.org/browse/DISPL-92
Here is an overview of the issue:
---------------------------------------------------------------------
Key: DISPL-92
Summary: Add support for javascript events on <tr> elements
Type: New Feature
Status: Unassigned
Priority: Major
Original Estimate: Unknown
Time Spent: Unknown
Remaining: Unknown
Project: DisplayTag
Components:
HTML Generation
Versions:
1.0 RC1
Assignee:
Reporter: Maarten Coene
Created: Mon, 8 Nov 2004 8:22 AM
Updated: Tue, 16 Nov 2004 10:58 PM
Description:
Hi,
we need to execute some javascript function when we click on a table row, but
there is no way to specify this with the curren taglib API.
We need something similar like the standars struts html tags where you can
specify a javascript funtion for each event.
For instance, it would be great if something like this could be added:
<display:table onrowclick="myfunction(this);">
...
</display>
this could generate:
<table>
<tr onclick="myfunction(this);">
...
</tr>
<tr onclick="myfunction(this);">
...
</tr>
</table>
the other javascript events could be handled simulary
regards,
Maarten
---------------------------------------------------------------------
JIRA INFORMATION:
This message is automatically generated by JIRA.
If you think it was sent incorrectly contact one of the administrators:
http://jira.codehaus.org/secure/Administrators.jspa
If you want more information on JIRA, or have a bug to report see:
http://www.atlassian.com/software/jira
-------------------------------------------------------
This SF.Net email is sponsored by: InterSystems CACHE
FREE OODBMS DOWNLOAD - A multidimensional database that combines
robust object and relational technologies, making it a perfect match
for Java, C++,COM, XML, ODBC and JDBC. www.intersystems.com/match8
_______________________________________________
displaytag-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/displaytag-devel