View source
City Project Amount Count
Carthago Gladiators 524.00 $ 4
Taxes 703.00 $ 5
Neapolis Arts 583.00 $ 0
Gladiators 45.00 $ 7
Olympia Arts 919.00 $ 5
Gladiators 308.00 $ 7
Gladiators 420.00 $ 0
Gladiators 721.00 $ 8
Roma Arts 30.00 $ 8
Gladiators 465.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 Gladiators 524.00 $ 4
Taxes 703.00 $ 5
Carthago subtotal1227.00 $9
Neapolis Arts 583.00 $ 0
Gladiators 45.00 $ 7
Neapolis subtotal628.00 $7
Olympia Arts 919.00 $ 5
Gladiators 308.00 $ 7
Gladiators 420.00 $ 0
Gladiators 721.00 $ 8
Olympia subtotal2368.00 $20
Roma Arts 30.00 $ 8
Gladiators 465.00 $ 7
Roma subtotal495.00 $15
Total4718.00 $51

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

Project City Amount Count
Arts Roma 30.00 $ 8
Neapolis 583.00 $ 0
Olympia 919.00 $ 5
partial amount1532.00 $
Gladiators Neapolis 45.00 $ 7
Olympia 308.00 $ 7
420.00 $ 0
Roma 465.00 $ 7
Carthago 524.00 $ 4
Olympia 721.00 $ 8
partial amount2483.00 $
Taxes Carthago 703.00 $ 5
partial amount703.00 $
full total4718.00 $

Totals for amount and count, without groups.

City Project Amount Count
Carthago Gladiators 524.00 $ 4
Carthago Taxes 703.00 $ 5
Neapolis Arts 583.00 $ 0
Neapolis Gladiators 45.00 $ 7
Olympia Arts 919.00 $ 5
Olympia Gladiators 308.00 $ 7
Olympia Gladiators 420.00 $ 0
Olympia Gladiators 721.00 $ 8
Roma Arts 30.00 $ 8
Roma Gladiators 465.00 $ 7
4718.00 $51

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
Gladiators
$524.00 4
Taxes
$703.00 5
Carthago Subtotal $1227.00 9
Neapolis
Arts
$583.00 0
Gladiators
$45.00 7
Neapolis Subtotal $628.00 7
Olympia
Arts
$919.00 5
Gladiators
$308.00 7
$420.00 0
$721.00 8
Gladiators Subtotal $1449.00 15
Olympia Subtotal $2368.00 20
Roma
Arts
$30.00 8
Gladiators
$465.00 7
Roma Subtotal $495.00 15
Total Across All Categories $4718.00 51