View source
City Project Amount Count
Carthago Gladiators 681.00 $ 1
Neapolis Arts 204.00 $ 6
Arts 386.00 $ 1
Olympia Arts 986.00 $ 7
Gladiators 17.00 $ 5
Gladiators 801.00 $ 0
Taxes 69.00 $ 7
Taxes 588.00 $ 4
Roma Army 141.00 $ 8
Taxes 172.00 $ 8

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 Gladiators 681.00 $ 1
Carthago subtotal681.00 $1
Neapolis Arts 204.00 $ 6
Arts 386.00 $ 1
Neapolis subtotal590.00 $7
Olympia Arts 986.00 $ 7
Gladiators 17.00 $ 5
Gladiators 801.00 $ 0
Taxes 69.00 $ 7
Taxes 588.00 $ 4
Olympia subtotal2461.00 $23
Roma Army 141.00 $ 8
Taxes 172.00 $ 8
Roma subtotal313.00 $16
Total4045.00 $47

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

Project City Amount Count
Army Roma 141.00 $ 8
partial amount141.00 $
Arts Neapolis 204.00 $ 6
386.00 $ 1
Olympia 986.00 $ 7
partial amount1576.00 $
Gladiators Olympia 17.00 $ 5
Carthago 681.00 $ 1
Olympia 801.00 $ 0
partial amount1499.00 $
Taxes Olympia 69.00 $ 7
Roma 172.00 $ 8
Olympia 588.00 $ 4
partial amount829.00 $
full total4045.00 $

Totals for amount and count, without groups.

City Project Amount Count
Carthago Gladiators 681.00 $ 1
Neapolis Arts 204.00 $ 6
Neapolis Arts 386.00 $ 1
Olympia Arts 986.00 $ 7
Olympia Gladiators 17.00 $ 5
Olympia Gladiators 801.00 $ 0
Olympia Taxes 69.00 $ 7
Olympia Taxes 588.00 $ 4
Roma Army 141.00 $ 8
Roma Taxes 172.00 $ 8
4045.00 $47

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
Gladiators
$681.00 1
Neapolis
Arts
$204.00 6
$386.00 1
Arts Subtotal $590.00 7
Neapolis Subtotal $590.00 7
Olympia
Arts
$986.00 7
Gladiators
$17.00 5
$801.00 0
Gladiators Subtotal $818.00 5
Taxes
$69.00 7
$588.00 4
Taxes Subtotal $657.00 11
Olympia Subtotal $2461.00 23
Roma
Army
$141.00 8
Taxes
$172.00 8
Roma Subtotal $313.00 16
Total Across All Categories $4045.00 47