View source
City Project Amount Count
Carthago Arts 576.00 $ 5
Gladiators 448.00 $ 6
Neapolis Army 424.00 $ 6
Taxes 243.00 $ 5
Taxes 889.00 $ 5
Olympia Arts 469.00 $ 1
Arts 564.00 $ 6
Arts 957.00 $ 0
Roma Army 88.00 $ 7
Arts 833.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 Arts 576.00 $ 5
Gladiators 448.00 $ 6
Carthago subtotal1024.00 $11
Neapolis Army 424.00 $ 6
Taxes 243.00 $ 5
Taxes 889.00 $ 5
Neapolis subtotal1556.00 $16
Olympia Arts 469.00 $ 1
Arts 564.00 $ 6
Arts 957.00 $ 0
Olympia subtotal1990.00 $7
Roma Army 88.00 $ 7
Arts 833.00 $ 2
Roma subtotal921.00 $9
Total5491.00 $43

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

Project City Amount Count
Army Roma 88.00 $ 7
Neapolis 424.00 $ 6
partial amount512.00 $
Arts Olympia 469.00 $ 1
564.00 $ 6
Carthago 576.00 $ 5
Roma 833.00 $ 2
Olympia 957.00 $ 0
partial amount3399.00 $
Gladiators Carthago 448.00 $ 6
partial amount448.00 $
Taxes Neapolis 243.00 $ 5
889.00 $ 5
partial amount1132.00 $
full total5491.00 $

Totals for amount and count, without groups.

City Project Amount Count
Carthago Arts 576.00 $ 5
Carthago Gladiators 448.00 $ 6
Neapolis Army 424.00 $ 6
Neapolis Taxes 243.00 $ 5
Neapolis Taxes 889.00 $ 5
Olympia Arts 469.00 $ 1
Olympia Arts 564.00 $ 6
Olympia Arts 957.00 $ 0
Roma Army 88.00 $ 7
Roma Arts 833.00 $ 2
5491.00 $43

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
$576.00 5
Gladiators
$448.00 6
Carthago Subtotal $1024.00 11
Neapolis
Army
$424.00 6
Taxes
$243.00 5
$889.00 5
Taxes Subtotal $1132.00 10
Neapolis Subtotal $1556.00 16
Olympia
Arts
$469.00 1
$564.00 6
$957.00 0
Arts Subtotal $1990.00 7
Olympia Subtotal $1990.00 7
Roma
Army
$88.00 7
Arts
$833.00 2
Roma Subtotal $921.00 9
Total Across All Categories $5491.00 43