View source
City Project Amount Count
Carthago Army 955.00 $ 3
Gladiators 610.00 $ 1
Neapolis Army 562.00 $ 9
Army 578.00 $ 0
Olympia Army 346.00 $ 5
Army 967.00 $ 8
Arts 281.00 $ 8
Arts 635.00 $ 2
Gladiators 351.00 $ 6
Roma Gladiators 402.00 $ 0

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 955.00 $ 3
Gladiators 610.00 $ 1
Carthago subtotal1565.00 $4
Neapolis Army 562.00 $ 9
Army 578.00 $ 0
Neapolis subtotal1140.00 $9
Olympia Army 346.00 $ 5
Army 967.00 $ 8
Arts 281.00 $ 8
Arts 635.00 $ 2
Gladiators 351.00 $ 6
Olympia subtotal2580.00 $29
Roma Gladiators 402.00 $ 0
Roma subtotal402.00 $0
Total5687.00 $42

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

Project City Amount Count
Army Olympia 346.00 $ 5
Neapolis 562.00 $ 9
578.00 $ 0
Carthago 955.00 $ 3
Olympia 967.00 $ 8
partial amount3408.00 $
Arts Olympia 281.00 $ 8
635.00 $ 2
partial amount916.00 $
Gladiators Olympia 351.00 $ 6
Roma 402.00 $ 0
Carthago 610.00 $ 1
partial amount1363.00 $
full total5687.00 $

Totals for amount and count, without groups.

City Project Amount Count
Carthago Army 955.00 $ 3
Carthago Gladiators 610.00 $ 1
Neapolis Army 562.00 $ 9
Neapolis Army 578.00 $ 0
Olympia Army 346.00 $ 5
Olympia Army 967.00 $ 8
Olympia Arts 281.00 $ 8
Olympia Arts 635.00 $ 2
Olympia Gladiators 351.00 $ 6
Roma Gladiators 402.00 $ 0
5687.00 $42

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
$955.00 3
Gladiators
$610.00 1
Carthago Subtotal $1565.00 4
Neapolis
Army
$562.00 9
$578.00 0
Army Subtotal $1140.00 9
Neapolis Subtotal $1140.00 9
Olympia
Army
$346.00 5
$967.00 8
Army Subtotal $1313.00 13
Arts
$281.00 8
$635.00 2
Arts Subtotal $916.00 10
Gladiators
$351.00 6
Olympia Subtotal $2580.00 29
Roma
Gladiators
$402.00 0
Total Across All Categories $5687.00 42