服务器管理 > 报告 > 高级报告脚本写入 > 在报告脚本中使用 JavaScript
在报告脚本中使用 JavaScript
您可以在 HTML 报告脚本中使用 JavaScript,使其更具动态效果,并为报告添加其他功能。
如果遇到 Windchill RV&S 报告标记无法处理的内容,您可以尝试使用 JavaScript 来完成。例如,Basic - HTML, Schedule 报告。
报告脚本中的 JavaScript 示例
用户很难跟踪报告中的项列表。他们希望报告中的行能以不同的颜色交替突出显示。Windchill RV&S 报告标记或 HTML 无法实现这一点。
在报告脚本中使用 JavaScript,可使报告中的每个项行以不同颜色显示。偶数行以一种颜色显示,奇数行以另一种颜色显示。
例如:
<%version 1%>
<%description <b>Description: </b>This is a report that uses basic
Windchill RVS report tags.<br><br>%>
<%param name="reporttitle" type="String" prompt="Report Title"
value="" description="Descriptive title for your report."%>
<%param name="reportheader" type="MultiString" prompt="Report
Header" value="" description="Text appearing at the top of
the report page."%>
<%param name="reportfooter" type="MultiString" prompt="Report
Footer" value="Confidential - Internal Use Only"
description="Text appearing at the bottom of the report page."%>
<html>
<head>
<title>Basic Report</title>
<%screenStyleSheet%>
<%printerStyleSheet%>
<script type="text/javascript">var line_count=0;</script>
</head>
<%dateformat%>
<%datetimeformat%>
<%sortby &sortby%>
<body>
<span class="logo"><%logoURL%></span>
<p class="title">&reporttitle</p>
<p class="header">&reportheader</p>
<div align="right" class="date"><%currentdate%></div>
<table class="display">
<tr><td colspan="&#fields"><hr class="hr_default"></td></tr>
<!-- Display item field headings -->
<tr>
<%iteratefields%>
<th class="heading1">&fielddisplayname</th>
<%/iteratefields%>
</tr> <tr><td colspan="&#fields"><hr class="hr_default"></td></tr>
<!-- Display item field values -->
<%begindetail%>
<script type="text/javascript">line_count++; if (line_count%2 == 0)
{document.write("<tr class='even_row'>");} else {document.write("<tr
class='odd_row'>");}</script>
<%iteratefields%>
<td class="border">&fieldname</td>
<%/iteratefields%>
</tr>\
<%enddetail%>
<tr><td colspan="&#fields"><hr class="hr_default"></td></tr>
</table>
<span class="footer">&reportfooter</span>
<div align="center">
<a href="<%weburl%>im/runreport?selection=&currentReportName">
<img src="<%weburl%>Report_Recipe/re-run_report.gif"
align="middle" border="0">
</a>
</div>
</body>
</html>
这对您有帮助吗?