View source
City Project Amount Count
Carthago Gladiators 723.00 $ 1
Taxes 223.00 $ 6
Neapolis Army 342.00 $ 3
Army 788.00 $ 6
Gladiators 544.00 $ 5
Taxes 769.00 $ 5
Olympia Arts 163.00 $ 3
Gladiators 638.00 $ 3
Roma Arts 680.00 $ 4
Gladiators 185.00 $ 3

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 723.00 $ 1
Taxes 223.00 $ 6
Carthago subtotal946.00 $7
Neapolis Army 342.00 $ 3
Army 788.00 $ 6
Gladiators 544.00 $ 5
Taxes 769.00 $ 5
Neapolis subtotal2443.00 $19
Olympia Arts 163.00 $ 3
Gladiators 638.00 $ 3
Olympia subtotal801.00 $6
Roma Arts 680.00 $ 4
Gladiators 185.00 $ 3
Roma subtotal865.00 $7
Total5055.00 $39

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

Project City Amount Count
Army Neapolis 342.00 $ 3
788.00 $ 6
partial amount1130.00 $
Arts Olympia 163.00 $ 3
Roma 680.00 $ 4
partial amount843.00 $
Gladiators Roma 185.00 $ 3
Neapolis 544.00 $ 5
Olympia 638.00 $ 3
Carthago 723.00 $ 1
partial amount2090.00 $
Taxes Carthago 223.00 $ 6
Neapolis 769.00 $ 5
partial amount992.00 $
full total5055.00 $

Totals for amount and count, without groups.

City Project Amount Count
Carthago Gladiators 723.00 $ 1
Carthago Taxes 223.00 $ 6
Neapolis Army 342.00 $ 3
Neapolis Army 788.00 $ 6
Neapolis Gladiators 544.00 $ 5
Neapolis Taxes 769.00 $ 5
Olympia Arts 163.00 $ 3
Olympia Gladiators 638.00 $ 3
Roma Arts 680.00 $ 4
Roma Gladiators 185.00 $ 3
5055.00 $39

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
$723.00 1
Taxes
$223.00 6
Carthago Subtotal $946.00 7
Neapolis
Army
$342.00 3
$788.00 6
Army Subtotal $1130.00 9
Gladiators
$544.00 5
Taxes
$769.00 5
Neapolis Subtotal $2443.00 19
Olympia
Arts
$163.00 3
Gladiators
$638.00 3
Olympia Subtotal $801.00 6
Roma
Arts
$680.00 4
Gladiators
$185.00 3
Roma Subtotal $865.00 7
Total Across All Categories $5055.00 39