View source
City Project Amount Count
Carthago Taxes 762.00 $ 5
Neapolis Gladiators 619.00 $ 2
Gladiators 922.00 $ 3
Olympia Army 609.00 $ 8
Arts 440.00 $ 2
Gladiators 192.00 $ 2
Gladiators 425.00 $ 6
Taxes 582.00 $ 3
Roma Gladiators 5.00 $ 8
Taxes 983.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 Taxes 762.00 $ 5
Carthago subtotal762.00 $5
Neapolis Gladiators 619.00 $ 2
Gladiators 922.00 $ 3
Neapolis subtotal1541.00 $5
Olympia Army 609.00 $ 8
Arts 440.00 $ 2
Gladiators 192.00 $ 2
Gladiators 425.00 $ 6
Taxes 582.00 $ 3
Olympia subtotal2248.00 $21
Roma Gladiators 5.00 $ 8
Taxes 983.00 $ 1
Roma subtotal988.00 $9
Total5539.00 $40

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

Project City Amount Count
Army Olympia 609.00 $ 8
partial amount609.00 $
Arts Olympia 440.00 $ 2
partial amount440.00 $
Gladiators Roma 5.00 $ 8
Olympia 192.00 $ 2
425.00 $ 6
Neapolis 619.00 $ 2
922.00 $ 3
partial amount2163.00 $
Taxes Olympia 582.00 $ 3
Carthago 762.00 $ 5
Roma 983.00 $ 1
partial amount2327.00 $
full total5539.00 $

Totals for amount and count, without groups.

City Project Amount Count
Carthago Taxes 762.00 $ 5
Neapolis Gladiators 619.00 $ 2
Neapolis Gladiators 922.00 $ 3
Olympia Army 609.00 $ 8
Olympia Arts 440.00 $ 2
Olympia Gladiators 192.00 $ 2
Olympia Gladiators 425.00 $ 6
Olympia Taxes 582.00 $ 3
Roma Gladiators 5.00 $ 8
Roma Taxes 983.00 $ 1
5539.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
$762.00 5
Neapolis
Gladiators
$619.00 2
$922.00 3
Gladiators Subtotal $1541.00 5
Neapolis Subtotal $1541.00 5
Olympia
Army
$609.00 8
Arts
$440.00 2
Gladiators
$192.00 2
$425.00 6
Gladiators Subtotal $617.00 8
Taxes
$582.00 3
Olympia Subtotal $2248.00 21
Roma
Gladiators
$5.00 8
Taxes
$983.00 1
Roma Subtotal $988.00 9
Total Across All Categories $5539.00 40