views:

1435

answers:

1

I'm looking for a way to do grouping with displaytag but with the group title separated from the detail. It's probably not all that clear, so here is an example :

If I just add groups to a displaytag table, I end up with something like :

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

I would like something like :

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

I cant find anything in the documentation. Does anyone knows if there is a work around ? Or should I just go back to simple, handwritten JTSL ?

+1  A: 

Sorry, to be 7 months late to the party, but try using the MultilevelTotalTableDecorator decorator, it generates a blank line as you requested, but it's really a side effect of what the decorator is supposed to do. You'll have to play around with the other options to get it to do what you want.

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