我们有一个带有隐藏列的显示表,总共4个(隐藏1个):
<display:table id="row" pagesize="10" sort="list" style="table-layout:fixed;">
<display:column title="id" class="hidden" headerClass="hidden">
${row_rowNum - 1}
</display:column>
<display:column title="Other Info" >
...
</display:column>
<display:column title="Other Info 2" >
...
</display:column>
<display:column title="Other Info 3" >
...
</display:column>
如果没有显示任何内容,则呈现的HTML为:
<td colspan="3">Nothing found to display.</td>
但这对我们造成了CSS问题,表格未对齐。它应该是ColSpan = 4:
<td colspan="4">Nothing found to display.</td>
为什么空消息ColSpan不计算隐藏列?
仅供参考,CSS风格&#34;隐藏&#34;是:
.hidden {
display: none;
}
答案 0 :(得分:2)
属性class="hidden"
只是将(css)类设置为"hidden"
,但该列仍会以HTML代码打印。
示例强>
<强> JSP 强>
<display:table name="mylist">
<display:column class="hidden" property="id"/>
<display:column property="name"/>
</display:table>
将生成以下HTML代码:
<table>
<tr>
<td class="hidden">ID#1</td>
<td>NAME#1</td>
</tr>
...
</table>
使用 CSS (.hidden { display: none;}
),您只是告诉浏览器在显示期间隐藏第一个<td>
- 标记。
<强>建议强>
在jsp代码中的if/else
构造处显示您自己的错误消息。
<%@ taglib prefix='c' uri='http://java.sun.com/jsp/jstl/core' %>
...
<c:choose>
<c:when test="${empty mylist}">
No data
</c:when>
<c:otherwise>
<display:table name="mylist">...</display:table>
</c:otherwise>
</c:if>
也许这也是一个displaytag问题。试着看看Github上的新开发,也许这个问题在那里得到解决。但据我记忆,没有活跃的社区。 p>