View source
City Project Amount Count
Carthago Army 928.00 $ 6
Arts 442.00 $ 4
Gladiators 995.00 $ 3
Taxes 442.00 $ 8
Neapolis Gladiators 932.00 $ 9
Olympia Army 623.00 $ 3
Arts 697.00 $ 6
Gladiators 543.00 $ 9
Gladiators 785.00 $ 7
Roma Gladiators 541.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 928.00 $ 6
Arts 442.00 $ 4
Gladiators 995.00 $ 3
Taxes 442.00 $ 8
Carthago subtotal2807.00 $21
Neapolis Gladiators 932.00 $ 9
Neapolis subtotal932.00 $9
Olympia Army 623.00 $ 3
Arts 697.00 $ 6
Gladiators 543.00 $ 9
Gladiators 785.00 $ 7
Olympia subtotal2648.00 $25
Roma Gladiators 541.00 $ 7
Roma subtotal541.00 $7
Total6928.00 $62

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

Project City Amount Count
Army Olympia 623.00 $ 3
Carthago 928.00 $ 6
partial amount1551.00 $
Arts Carthago 442.00 $ 4
Olympia 697.00 $ 6
partial amount1139.00 $
Gladiators Roma 541.00 $ 7
Olympia 543.00 $ 9
785.00 $ 7
Neapolis 932.00 $ 9
Carthago 995.00 $ 3
partial amount3796.00 $
Taxes Carthago 442.00 $ 8
partial amount442.00 $
full total6928.00 $

Totals for amount and count, without groups.

City Project Amount Count
Carthago Army 928.00 $ 6
Carthago Arts 442.00 $ 4
Carthago Gladiators 995.00 $ 3
Carthago Taxes 442.00 $ 8
Neapolis Gladiators 932.00 $ 9
Olympia Army 623.00 $ 3
Olympia Arts 697.00 $ 6
Olympia Gladiators 543.00 $ 9
Olympia Gladiators 785.00 $ 7
Roma Gladiators 541.00 $ 7
6928.00 $62

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
$928.00 6
Arts
$442.00 4
Gladiators
$995.00 3
Taxes
$442.00 8
Carthago Subtotal $2807.00 21
Neapolis
Gladiators
$932.00 9
Olympia
Army
$623.00 3
Arts
$697.00 6
Gladiators
$543.00 9
$785.00 7
Gladiators Subtotal $1328.00 16
Olympia Subtotal $2648.00 25
Roma
Gladiators
$541.00 7
Total Across All Categories $6928.00 62