View source
City Project Amount Count
Carthago Taxes 137.00 $ 3
Taxes 952.00 $ 3
Neapolis Army 281.00 $ 4
Army 673.00 $ 4
Arts 879.00 $ 2
Gladiators 218.00 $ 9
Olympia Army 799.00 $ 0
Arts 943.00 $ 1
Roma Gladiators 968.00 $ 0
Taxes 661.00 $ 9

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 Taxes 137.00 $ 3
Taxes 952.00 $ 3
Carthago subtotal1089.00 $6
Neapolis Army 281.00 $ 4
Army 673.00 $ 4
Arts 879.00 $ 2
Gladiators 218.00 $ 9
Neapolis subtotal2051.00 $19
Olympia Army 799.00 $ 0
Arts 943.00 $ 1
Olympia subtotal1742.00 $1
Roma Gladiators 968.00 $ 0
Taxes 661.00 $ 9
Roma subtotal1629.00 $9
Total6511.00 $35

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

Project City Amount Count
Army Neapolis 281.00 $ 4
673.00 $ 4
Olympia 799.00 $ 0
partial amount1753.00 $
Arts Neapolis 879.00 $ 2
Olympia 943.00 $ 1
partial amount1822.00 $
Gladiators Neapolis 218.00 $ 9
Roma 968.00 $ 0
partial amount1186.00 $
Taxes Carthago 137.00 $ 3
Roma 661.00 $ 9
Carthago 952.00 $ 3
partial amount1750.00 $
full total6511.00 $

Totals for amount and count, without groups.

City Project Amount Count
Carthago Taxes 137.00 $ 3
Carthago Taxes 952.00 $ 3
Neapolis Army 281.00 $ 4
Neapolis Army 673.00 $ 4
Neapolis Arts 879.00 $ 2
Neapolis Gladiators 218.00 $ 9
Olympia Army 799.00 $ 0
Olympia Arts 943.00 $ 1
Roma Gladiators 968.00 $ 0
Roma Taxes 661.00 $ 9
6511.00 $35

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
Taxes
$137.00 3
$952.00 3
Taxes Subtotal $1089.00 6
Carthago Subtotal $1089.00 6
Neapolis
Army
$281.00 4
$673.00 4
Army Subtotal $954.00 8
Arts
$879.00 2
Gladiators
$218.00 9
Neapolis Subtotal $2051.00 19
Olympia
Army
$799.00 0
Arts
$943.00 1
Olympia Subtotal $1742.00 1
Roma
Gladiators
$968.00 0
Taxes
$661.00 9
Roma Subtotal $1629.00 9
Total Across All Categories $6511.00 35