View source
City Project Amount Count
Carthago Arts 414.00 $ 3
Neapolis Arts 945.00 $ 1
Gladiators 844.00 $ 5
Olympia Army 669.00 $ 4
Arts 468.00 $ 1
Gladiators 853.00 $ 2
Roma Army 525.00 $ 7
Army 956.00 $ 1
Arts 87.00 $ 9
Arts 317.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 Arts 414.00 $ 3
Carthago subtotal414.00 $3
Neapolis Arts 945.00 $ 1
Gladiators 844.00 $ 5
Neapolis subtotal1789.00 $6
Olympia Army 669.00 $ 4
Arts 468.00 $ 1
Gladiators 853.00 $ 2
Olympia subtotal1990.00 $7
Roma Army 525.00 $ 7
Army 956.00 $ 1
Arts 87.00 $ 9
Arts 317.00 $ 0
Roma subtotal1885.00 $17
Total6078.00 $33

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

Project City Amount Count
Army Roma 525.00 $ 7
Olympia 669.00 $ 4
Roma 956.00 $ 1
partial amount2150.00 $
Arts Roma 87.00 $ 9
317.00 $ 0
Carthago 414.00 $ 3
Olympia 468.00 $ 1
Neapolis 945.00 $ 1
partial amount2231.00 $
Gladiators Neapolis 844.00 $ 5
Olympia 853.00 $ 2
partial amount1697.00 $
full total6078.00 $

Totals for amount and count, without groups.

City Project Amount Count
Carthago Arts 414.00 $ 3
Neapolis Arts 945.00 $ 1
Neapolis Gladiators 844.00 $ 5
Olympia Army 669.00 $ 4
Olympia Arts 468.00 $ 1
Olympia Gladiators 853.00 $ 2
Roma Army 525.00 $ 7
Roma Army 956.00 $ 1
Roma Arts 87.00 $ 9
Roma Arts 317.00 $ 0
6078.00 $33

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
Arts
$414.00 3
Neapolis
Arts
$945.00 1
Gladiators
$844.00 5
Neapolis Subtotal $1789.00 6
Olympia
Army
$669.00 4
Arts
$468.00 1
Gladiators
$853.00 2
Olympia Subtotal $1990.00 7
Roma
Army
$525.00 7
$956.00 1
Army Subtotal $1481.00 8
Arts
$87.00 9
$317.00 0
Arts Subtotal $404.00 9
Roma Subtotal $1885.00 17
Total Across All Categories $6078.00 33