代码之家  ›  专栏  ›  技术社区  ›  Guillaume

显示标记、分组和空行

  •  0
  • Guillaume  · 技术社区  · 16 年前

    displaytag 但组名和细节是分开的。可能不是很清楚,下面是一个例子:

    | group1 | item1 |
    |        | item2 |
    |        | item3 |
    | group2 | item4 |
    |        | item5 |
    

    我想要一些像:

    | group1 |       | 
    |        | item1 |
    |        | item2 |
    |        | item3 |
    | group2 |       |
    |        | item4 |
    |        | item5 |
    

    我在文件里找不到任何东西。有人知道附近有没有工作吗?还是应该回到简单的手写JTSL?

    1 回复  |  直到 8 年前
        1
  •  1
  •   Roy Rico Alexandr Lazarev    15 年前

    抱歉,迟到了7个月,但请尝试使用 MultilevelTotalTableDecorator decorator,它根据您的请求生成一个空行,但这实际上是decorator应该做的一个副作用。你要想让它做你想做的事,你得考虑其他的选择。

    <%
            // you can do this as a scriptlet on the page, but i put it into a taglib...
            org.displaytag.decorator.MultilevelTotalTableDecorator subtotals = new org.displaytag.decorator.MultilevelTotalTableDecorator();
            subtotals.setGrandTotalDescription("&nbsp;");    // optional, defaults to Grand Total
            subtotals.setSubtotalLabel("&nbsp;", null);
            pageContext.getRequest().setAttribute("subtotaler", subtotals);
    %>
    <display:table name="contacts" id="contactRow" defaultsort="1" defaultorder="ascending" decorator="subtotaler">
        <display:column property="contactType" title="Contact Type" total="true" group="1"/>
        <display:column property="contactDate" format="{0,date,MM/dd/yyyy}" title="Date" />
        <display:column property="contactName" title="Name" />
        <display:column property="contactPhone" title="Phone" />
        <display:column property="contactEmail" title="Email" />
    </display:table>