View source
City Project Amount Count
Carthago Army 629.00 $ 2
Taxes 221.00 $ 9
Taxes 770.00 $ 9
Neapolis Gladiators 927.00 $ 4
Taxes 60.00 $ 3
Olympia Arts 310.00 $ 4
Arts 883.00 $ 1
Arts 960.00 $ 4
Roma Army 823.00 $ 1
Taxes 268.00 $ 9

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 629.00 $ 2
Taxes 221.00 $ 9
Taxes 770.00 $ 9
Carthago subtotal1620.00 $20
Neapolis Gladiators 927.00 $ 4
Taxes 60.00 $ 3
Neapolis subtotal987.00 $7
Olympia Arts 310.00 $ 4
Arts 883.00 $ 1
Arts 960.00 $ 4
Olympia subtotal2153.00 $9
Roma Army 823.00 $ 1
Taxes 268.00 $ 9
Roma subtotal1091.00 $10
Total5851.00 $46

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

Project City Amount Count
Army Carthago 629.00 $ 2
Roma 823.00 $ 1
partial amount1452.00 $
Arts Olympia 310.00 $ 4
883.00 $ 1
960.00 $ 4
partial amount2153.00 $
Gladiators Neapolis 927.00 $ 4
partial amount927.00 $
Taxes Neapolis 60.00 $ 3
Carthago 221.00 $ 9
Roma 268.00 $ 9
Carthago 770.00 $ 9
partial amount1319.00 $
full total5851.00 $

Totals for amount and count, without groups.

City Project Amount Count
Carthago Army 629.00 $ 2
Carthago Taxes 221.00 $ 9
Carthago Taxes 770.00 $ 9
Neapolis Gladiators 927.00 $ 4
Neapolis Taxes 60.00 $ 3
Olympia Arts 310.00 $ 4
Olympia Arts 883.00 $ 1
Olympia Arts 960.00 $ 4
Roma Army 823.00 $ 1
Roma Taxes 268.00 $ 9
5851.00 $46

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
$629.00 2
Taxes
$221.00 9
$770.00 9
Taxes Subtotal $991.00 18
Carthago Subtotal $1620.00 20
Neapolis
Gladiators
$927.00 4
Taxes
$60.00 3
Neapolis Subtotal $987.00 7
Olympia
Arts
$310.00 4
$883.00 1
$960.00 4
Arts Subtotal $2153.00 9
Olympia Subtotal $2153.00 9
Roma
Army
$823.00 1
Taxes
$268.00 9
Roma Subtotal $1091.00 10
Total Across All Categories $5851.00 46