1

我有一个使用 Proc Report 制作的 ODS HTML 表格,我需要将 HTML 类属性添加到表格行<tr>,而不是该行中的每个单独<td>的单元格。原因是在 TableSorter jQuery 插件中的 stickyRow 选项中需要这样做,以防止它无法像表格的其余部分一样进行排序。

该行(总和行)是在计算语句中创建的。

以下语句将<td>行中每个单元格的类设置为“静态”,但不是<tr>选项中所需的。

过程报告

compute BEFORE;
&variabel. = 'Totalt';
call define (_ROW_,"style","style={flyover='Totalt' FONT_WEIGHT=bold 
background=lightgrey class='static'}");
ENDCOMP;

HTML 对此进行了解析:

<tr>
<td title="Totalt" class="l static" style=" background-color: #d3d3d3; font-weight: bold;”&gt;T</a></td>
<td title="Totalt" class="r static" style=" background-color: #d3d3d3; font-weight: bold;"> 44,737,223</td>
<td title="Totalt" class="r static" style=" background-color: #d3d3d3; font-weight: bold;"> 43,321,900</td>

有没有办法将整个<tr>-row 的类设置为“静态”,而不是每个单元格?

以下是我需要的样子:

<tr class="static">
<td title="Totalt" class="l" style=" background-color: #d3d3d3; font-weight: bold;”&gt;T</a></td>
<td title="Totalt" class="r" style=" background-color: #d3d3d3; font-weight: bold;"> 44,737,223</td>
<td title="Totalt" class="r" style=" background-color: #d3d3d3; font-weight: bold;"> 43,321,900</td>

更新:这是一个可重现的示例:

ODS HTML FILE='H:\Temp\demo.html';
ODS HTML TEXT="
<script src='https://code.jquery.com/jquery-3.2.1.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/jquery.tablesorter/2.28.15/js/jquery.tablesorter.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/jquery.tablesorter/2.28.15/js/jquery.tablesorter.widgets.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/jquery.tablesorter/2.28.15/js/widgets/widget-staticRow.min.js'></script>";

ODS HTML TEXT="
<script>    
$(function(){
$(document).ready(function() { 
$('.table').tablesorter({theme: 'blue', widgets: ['stickyHeaders','zebra','staticRow']});
});
});
</script>";

PROC REPORT DATA=SASHELP.CLASS;
COLUMN SEX AGE N WEIGHT;
DEFINE sex /DISPLAY;
DEFINE age /DISPLAY;
DEFINE weight / ANALYSIS;
RBREAK BEFORE/SUMMARIZE;
COMPUTE before;
CALL DEFINE (_ROW_,"style","style={flyover='Total number and weight' FONT_WEIGHT=bold background=lightgrey class='static'}");
ENDCOMP;
RUN;

ODS HTML CLOSE;
4

1 回答 1

0

I've done something similar when integrating jQuery Datatables with PROC REPORT.

From memory, you need to edit the htmlcss and/or phtml tagsets, amending the table_foot and row events, but I can't recall exactly what I did.

I'll try to find my code, and update answer accordingly.

于 2017-08-11T14:36:14.830 回答