显示带有隐藏列的标记:"Nothing Found to Display" 的 COLSPAN 错误

Display Tag with Hidden Column: "Nothing Found to Display" has Wrong COLSPAN

我们有一个带有隐藏列的显示 Table,总共 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 问题,table 未对齐。应该是 ColSpan=4:

<td colspan="4">Nothing found to display.</td>

为什么空消息 ColSpan 不计算隐藏列?

仅供参考,CSS 样式 "hidden" 是:

.hidden {
    display: none;
}

属性class="hidden"只是将(css)-class设置为"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>

也许这也是一个显示标签问题。试着看看 Github 上的最新开发,也许这个问题在那里解决了。但是据我所知没有活跃的社区。