View source
City Project Amount Count
Carthago Taxes 770.00 $ 2
Neapolis Arts 142.00 $ 7
Taxes 977.00 $ 4
Olympia Arts 684.00 $ 1
Gladiators 726.00 $ 8
Taxes 127.00 $ 0
Roma Army 790.00 $ 3
Taxes 281.00 $ 2
Taxes 809.00 $ 5
Taxes 871.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 Taxes 770.00 $ 2
Carthago subtotal770.00 $2
Neapolis Arts 142.00 $ 7
Taxes 977.00 $ 4
Neapolis subtotal1119.00 $11
Olympia Arts 684.00 $ 1
Gladiators 726.00 $ 8
Taxes 127.00 $ 0
Olympia subtotal1537.00 $9
Roma Army 790.00 $ 3
Taxes 281.00 $ 2
Taxes 809.00 $ 5
Taxes 871.00 $ 8
Roma subtotal2751.00 $18
Total6177.00 $40

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

Project City Amount Count
Army Roma 790.00 $ 3
partial amount790.00 $
Arts Neapolis 142.00 $ 7
Olympia 684.00 $ 1
partial amount826.00 $
Gladiators Olympia 726.00 $ 8
partial amount726.00 $
Taxes Olympia 127.00 $ 0
Roma 281.00 $ 2
Carthago 770.00 $ 2
Roma 809.00 $ 5
871.00 $ 8
Neapolis 977.00 $ 4
partial amount3835.00 $
full total6177.00 $

Totals for amount and count, without groups.

City Project Amount Count
Carthago Taxes 770.00 $ 2
Neapolis Arts 142.00 $ 7
Neapolis Taxes 977.00 $ 4
Olympia Arts 684.00 $ 1
Olympia Gladiators 726.00 $ 8
Olympia Taxes 127.00 $ 0
Roma Army 790.00 $ 3
Roma Taxes 281.00 $ 2
Roma Taxes 809.00 $ 5
Roma Taxes 871.00 $ 8
6177.00 $40

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
$770.00 2
Neapolis
Arts
$142.00 7
Taxes
$977.00 4
Neapolis Subtotal $1119.00 11
Olympia
Arts
$684.00 1
Gladiators
$726.00 8
Taxes
$127.00 0
Olympia Subtotal $1537.00 9
Roma
Army
$790.00 3
Taxes
$281.00 2
$809.00 5
$871.00 8
Taxes Subtotal $1961.00 15
Roma Subtotal $2751.00 18
Total Across All Categories $6177.00 40