View source
City Project Amount Count
Carthago Taxes 145.00 $ 6
Neapolis Army 98.00 $ 2
Arts 431.00 $ 3
Olympia Army 635.00 $ 5
Arts 693.00 $ 8
Taxes 383.00 $ 9
Taxes 701.00 $ 4
Roma Gladiators 270.00 $ 9
Gladiators 711.00 $ 1
Taxes 897.00 $ 2

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 145.00 $ 6
Carthago subtotal145.00 $6
Neapolis Army 98.00 $ 2
Arts 431.00 $ 3
Neapolis subtotal529.00 $5
Olympia Army 635.00 $ 5
Arts 693.00 $ 8
Taxes 383.00 $ 9
Taxes 701.00 $ 4
Olympia subtotal2412.00 $26
Roma Gladiators 270.00 $ 9
Gladiators 711.00 $ 1
Taxes 897.00 $ 2
Roma subtotal1878.00 $12
Total4964.00 $49

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

Project City Amount Count
Army Neapolis 98.00 $ 2
Olympia 635.00 $ 5
partial amount733.00 $
Arts Neapolis 431.00 $ 3
Olympia 693.00 $ 8
partial amount1124.00 $
Gladiators Roma 270.00 $ 9
711.00 $ 1
partial amount981.00 $
Taxes Carthago 145.00 $ 6
Olympia 383.00 $ 9
701.00 $ 4
Roma 897.00 $ 2
partial amount2126.00 $
full total4964.00 $

Totals for amount and count, without groups.

City Project Amount Count
Carthago Taxes 145.00 $ 6
Neapolis Army 98.00 $ 2
Neapolis Arts 431.00 $ 3
Olympia Army 635.00 $ 5
Olympia Arts 693.00 $ 8
Olympia Taxes 383.00 $ 9
Olympia Taxes 701.00 $ 4
Roma Gladiators 270.00 $ 9
Roma Gladiators 711.00 $ 1
Roma Taxes 897.00 $ 2
4964.00 $49

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
$145.00 6
Neapolis
Army
$98.00 2
Arts
$431.00 3
Neapolis Subtotal $529.00 5
Olympia
Army
$635.00 5
Arts
$693.00 8
Taxes
$383.00 9
$701.00 4
Taxes Subtotal $1084.00 13
Olympia Subtotal $2412.00 26
Roma
Gladiators
$270.00 9
$711.00 1
Gladiators Subtotal $981.00 10
Taxes
$897.00 2
Roma Subtotal $1878.00 12
Total Across All Categories $4964.00 49