View source
City Project Amount Count
Carthago Army 295.00 $ 0
Army 663.00 $ 8
Gladiators 611.00 $ 6
Neapolis Army 285.00 $ 4
Olympia Taxes 134.00 $ 4
Taxes 855.00 $ 9
Roma Army 676.00 $ 9
Arts 486.00 $ 2
Taxes 524.00 $ 9
Taxes 703.00 $ 2

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 295.00 $ 0
Army 663.00 $ 8
Gladiators 611.00 $ 6
Carthago subtotal1569.00 $14
Neapolis Army 285.00 $ 4
Neapolis subtotal285.00 $4
Olympia Taxes 134.00 $ 4
Taxes 855.00 $ 9
Olympia subtotal989.00 $13
Roma Army 676.00 $ 9
Arts 486.00 $ 2
Taxes 524.00 $ 9
Taxes 703.00 $ 2
Roma subtotal2389.00 $22
Total5232.00 $53

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

Project City Amount Count
Army Neapolis 285.00 $ 4
Carthago 295.00 $ 0
663.00 $ 8
Roma 676.00 $ 9
partial amount1919.00 $
Arts Roma 486.00 $ 2
partial amount486.00 $
Gladiators Carthago 611.00 $ 6
partial amount611.00 $
Taxes Olympia 134.00 $ 4
Roma 524.00 $ 9
703.00 $ 2
Olympia 855.00 $ 9
partial amount2216.00 $
full total5232.00 $

Totals for amount and count, without groups.

City Project Amount Count
Carthago Army 295.00 $ 0
Carthago Army 663.00 $ 8
Carthago Gladiators 611.00 $ 6
Neapolis Army 285.00 $ 4
Olympia Taxes 134.00 $ 4
Olympia Taxes 855.00 $ 9
Roma Army 676.00 $ 9
Roma Arts 486.00 $ 2
Roma Taxes 524.00 $ 9
Roma Taxes 703.00 $ 2
5232.00 $53

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
$295.00 0
$663.00 8
Army Subtotal $958.00 8
Gladiators
$611.00 6
Carthago Subtotal $1569.00 14
Neapolis
Army
$285.00 4
Olympia
Taxes
$134.00 4
$855.00 9
Taxes Subtotal $989.00 13
Olympia Subtotal $989.00 13
Roma
Army
$676.00 9
Arts
$486.00 2
Taxes
$524.00 9
$703.00 2
Taxes Subtotal $1227.00 11
Roma Subtotal $2389.00 22
Total Across All Categories $5232.00 53