View source
City Project Amount Count
Carthago Arts 716.00 $ 5
Taxes 673.00 $ 8
Taxes 898.00 $ 9
Neapolis Army 812.00 $ 2
Army 945.00 $ 3
Gladiators 62.00 $ 6
Olympia Army 4.00 $ 2
Army 295.00 $ 8
Arts 610.00 $ 2
Taxes 165.00 $ 1

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 716.00 $ 5
Taxes 673.00 $ 8
Taxes 898.00 $ 9
Carthago subtotal2287.00 $22
Neapolis Army 812.00 $ 2
Army 945.00 $ 3
Gladiators 62.00 $ 6
Neapolis subtotal1819.00 $11
Olympia Army 4.00 $ 2
Army 295.00 $ 8
Arts 610.00 $ 2
Taxes 165.00 $ 1
Olympia subtotal1074.00 $13
Total5180.00 $46

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

Project City Amount Count
Army Olympia 4.00 $ 2
295.00 $ 8
Neapolis 812.00 $ 2
945.00 $ 3
partial amount2056.00 $
Arts Olympia 610.00 $ 2
Carthago 716.00 $ 5
partial amount1326.00 $
Gladiators Neapolis 62.00 $ 6
partial amount62.00 $
Taxes Olympia 165.00 $ 1
Carthago 673.00 $ 8
898.00 $ 9
partial amount1736.00 $
full total5180.00 $

Totals for amount and count, without groups.

City Project Amount Count
Carthago Arts 716.00 $ 5
Carthago Taxes 673.00 $ 8
Carthago Taxes 898.00 $ 9
Neapolis Army 812.00 $ 2
Neapolis Army 945.00 $ 3
Neapolis Gladiators 62.00 $ 6
Olympia Army 4.00 $ 2
Olympia Army 295.00 $ 8
Olympia Arts 610.00 $ 2
Olympia Taxes 165.00 $ 1
5180.00 $46

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
$716.00 5
Taxes
$673.00 8
$898.00 9
Taxes Subtotal $1571.00 17
Carthago Subtotal $2287.00 22
Neapolis
Army
$812.00 2
$945.00 3
Army Subtotal $1757.00 5
Gladiators
$62.00 6
Neapolis Subtotal $1819.00 11
Olympia
Army
$4.00 2
$295.00 8
Army Subtotal $299.00 10
Arts
$610.00 2
Taxes
$165.00 1
Olympia Subtotal $1074.00 13
Total Across All Categories $5180.00 46