View source
City Project Amount Count
Carthago Army 887.00 $ 0
Gladiators 229.00 $ 3
Gladiators 434.00 $ 6
Neapolis Taxes 25.00 $ 8
Taxes 240.00 $ 0
Olympia Army 871.00 $ 9
Arts 74.00 $ 7
Roma Gladiators 272.00 $ 7
Taxes 602.00 $ 9
Taxes 782.00 $ 6

The table above shows a simple report, grouped by the "city" value, and with some amount.

The following tables are based on the same code, with the only addition of a table decorator org.displaytag.decorator.TotalTableDecorator .

The decorator will generate totals for any column with the total attribute set, and subtotal rows by grouping using the column with a group attribute set to 1.


Group by city, total for amount and count

City Project Amount Count
Carthago Army 887.00 $ 0
Gladiators 229.00 $ 3
Gladiators 434.00 $ 6
Carthago subtotal1550.00 $9
Neapolis Taxes 25.00 $ 8
Taxes 240.00 $ 0
Neapolis subtotal265.00 $8
Olympia Army 871.00 $ 9
Arts 74.00 $ 7
Olympia subtotal945.00 $16
Roma Gladiators 272.00 $ 7
Taxes 602.00 $ 9
Taxes 782.00 $ 6
Roma subtotal1656.00 $22
Total4416.00 $55

Group by project and city, totals for amount only, customize labels.

Project City Amount Count
Army Olympia 871.00 $ 9
Carthago 887.00 $ 0
partial amount1758.00 $
Arts Olympia 74.00 $ 7
partial amount74.00 $
Gladiators Carthago 229.00 $ 3
Roma 272.00 $ 7
Carthago 434.00 $ 6
partial amount935.00 $
Taxes Neapolis 25.00 $ 8
240.00 $ 0
Roma 602.00 $ 9
782.00 $ 6
partial amount1649.00 $
full total4416.00 $

Totals for amount and count, without groups.

City Project Amount Count
Carthago Army 887.00 $ 0
Carthago Gladiators 229.00 $ 3
Carthago Gladiators 434.00 $ 6
Neapolis Taxes 25.00 $ 8
Neapolis Taxes 240.00 $ 0
Olympia Army 871.00 $ 9
Olympia Arts 74.00 $ 7
Roma Gladiators 272.00 $ 7
Roma Taxes 602.00 $ 9
Roma Taxes 782.00 $ 6
4416.00 $55

If you need subtotals for subgroups, try the MultilevelTotalTableDecorator. Items with only one entry are not totaled separately, but items that occur more than once are subtotaled together.

City Project Amount Count
Carthago
Army
$887.00 0
Gladiators
$229.00 3
$434.00 6
Gladiators Subtotal $663.00 9
Carthago Subtotal $1550.00 9
Neapolis
Taxes
$25.00 8
$240.00 0
Taxes Subtotal $265.00 8
Neapolis Subtotal $265.00 8
Olympia
Army
$871.00 9
Arts
$74.00 7
Olympia Subtotal $945.00 16
Roma
Gladiators
$272.00 7
Taxes
$602.00 9
$782.00 6
Taxes Subtotal $1384.00 15
Roma Subtotal $1656.00 22
Total Across All Categories $4416.00 55