有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java显示标记、分组和空行

我正在寻找一种使用displaytag进行分组的方法,但是将组标题与细节分开。这可能不是很清楚,所以这里有一个例子:

如果我只是将组添加到displaytag表中,我会得到如下结果:

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

我想要一些像:

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

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


共 (1) 个答案

  1. # 1 楼答案

    抱歉,聚会迟到了7个月,但是试着使用MultilevelTotalTableDecorator装饰器,它会按照您的要求生成一个空行,但这实际上是装饰器应该做的事情的副作用。你将不得不使用其他选项来让它做你想做的事情

    <%
            // 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>