View source
City Project Amount Count
Carthago Gladiators 49.00 $ 7
Gladiators 658.00 $ 9
Neapolis Gladiators 12.00 $ 2
Gladiators 193.00 $ 6
Taxes 103.00 $ 5
Olympia Arts 225.00 $ 0
Arts 974.00 $ 3
Gladiators 29.00 $ 0
Gladiators 837.00 $ 6
Roma Arts 886.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 49.00 $ 7
Gladiators 658.00 $ 9
Carthago subtotal707.00 $16
Neapolis Gladiators 12.00 $ 2
Gladiators 193.00 $ 6
Taxes 103.00 $ 5
Neapolis subtotal308.00 $13
Olympia Arts 225.00 $ 0
Arts 974.00 $ 3
Gladiators 29.00 $ 0
Gladiators 837.00 $ 6
Olympia subtotal2065.00 $9
Roma Arts 886.00 $ 7
Roma subtotal886.00 $7
Total3966.00 $45

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

Project City Amount Count
Arts Olympia 225.00 $ 0
Roma 886.00 $ 7
Olympia 974.00 $ 3
partial amount2085.00 $
Gladiators Neapolis 12.00 $ 2
Olympia 29.00 $ 0
Carthago 49.00 $ 7
Neapolis 193.00 $ 6
Carthago 658.00 $ 9
Olympia 837.00 $ 6
partial amount1778.00 $
Taxes Neapolis 103.00 $ 5
partial amount103.00 $
full total3966.00 $

Totals for amount and count, without groups.

City Project Amount Count
Carthago Gladiators 49.00 $ 7
Carthago Gladiators 658.00 $ 9
Neapolis Gladiators 12.00 $ 2
Neapolis Gladiators 193.00 $ 6
Neapolis Taxes 103.00 $ 5
Olympia Arts 225.00 $ 0
Olympia Arts 974.00 $ 3
Olympia Gladiators 29.00 $ 0
Olympia Gladiators 837.00 $ 6
Roma Arts 886.00 $ 7
3966.00 $45

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
$49.00 7
$658.00 9
Gladiators Subtotal $707.00 16
Carthago Subtotal $707.00 16
Neapolis
Gladiators
$12.00 2
$193.00 6
Gladiators Subtotal $205.00 8
Taxes
$103.00 5
Neapolis Subtotal $308.00 13
Olympia
Arts
$225.00 0
$974.00 3
Arts Subtotal $1199.00 3
Gladiators
$29.00 0
$837.00 6
Gladiators Subtotal $866.00 6
Olympia Subtotal $2065.00 9
Roma
Arts
$886.00 7
Total Across All Categories $3966.00 45