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



我们有一个带有隐藏列的显示表,总共 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样式"隐藏"是:

.hidden {
    display: none;
}

属性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>

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

相关内容

最新更新