View source
City Project Amount Count
Carthago Army 809.00 $ 8
Arts 126.00 $ 5
Neapolis Gladiators 452.00 $ 8
Taxes 54.00 $ 9
Taxes 105.00 $ 0
Olympia Gladiators 8.00 $ 4
Gladiators 467.00 $ 3
Roma Army 272.00 $ 1
Army 393.00 $ 9
Arts 435.00 $ 7

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 Army 809.00 $ 8
Arts 126.00 $ 5
Carthago subtotal935.00 $13
Neapolis Gladiators 452.00 $ 8
Taxes 54.00 $ 9
Taxes 105.00 $ 0
Neapolis subtotal611.00 $17
Olympia Gladiators 8.00 $ 4
Gladiators 467.00 $ 3
Olympia subtotal475.00 $7
Roma Army 272.00 $ 1
Army 393.00 $ 9
Arts 435.00 $ 7
Roma subtotal1100.00 $17
Total3121.00 $54

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

Project City Amount Count
Army Roma 272.00 $ 1
393.00 $ 9
Carthago 809.00 $ 8
partial amount1474.00 $
Arts Carthago 126.00 $ 5
Roma 435.00 $ 7
partial amount561.00 $
Gladiators Olympia 8.00 $ 4
Neapolis 452.00 $ 8
Olympia 467.00 $ 3
partial amount927.00 $
Taxes Neapolis 54.00 $ 9
105.00 $ 0
partial amount159.00 $
full total3121.00 $

Totals for amount and count, without groups.

City Project Amount Count
Carthago Army 809.00 $ 8
Carthago Arts 126.00 $ 5
Neapolis Gladiators 452.00 $ 8
Neapolis Taxes 54.00 $ 9
Neapolis Taxes 105.00 $ 0
Olympia Gladiators 8.00 $ 4
Olympia Gladiators 467.00 $ 3
Roma Army 272.00 $ 1
Roma Army 393.00 $ 9
Roma Arts 435.00 $ 7
3121.00 $54

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
Army
$809.00 8
Arts
$126.00 5
Carthago Subtotal $935.00 13
Neapolis
Gladiators
$452.00 8
Taxes
$54.00 9
$105.00 0
Taxes Subtotal $159.00 9
Neapolis Subtotal $611.00 17
Olympia
Gladiators
$8.00 4
$467.00 3
Gladiators Subtotal $475.00 7
Olympia Subtotal $475.00 7
Roma
Army
$272.00 1
$393.00 9
Army Subtotal $665.00 10
Arts
$435.00 7
Roma Subtotal $1100.00 17
Total Across All Categories $3121.00 54