View source
City Project Amount Count
Carthago Taxes 723.00 $ 9
Neapolis Army 319.00 $ 8
Army 964.00 $ 4
Gladiators 185.00 $ 3
Olympia Taxes 609.00 $ 2
Roma Army 671.00 $ 5
Arts 147.00 $ 8
Arts 207.00 $ 0
Gladiators 725.00 $ 1
Taxes 719.00 $ 9

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 723.00 $ 9
Carthago subtotal723.00 $9
Neapolis Army 319.00 $ 8
Army 964.00 $ 4
Gladiators 185.00 $ 3
Neapolis subtotal1468.00 $15
Olympia Taxes 609.00 $ 2
Olympia subtotal609.00 $2
Roma Army 671.00 $ 5
Arts 147.00 $ 8
Arts 207.00 $ 0
Gladiators 725.00 $ 1
Taxes 719.00 $ 9
Roma subtotal2469.00 $23
Total5269.00 $49

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

Project City Amount Count
Army Neapolis 319.00 $ 8
Roma 671.00 $ 5
Neapolis 964.00 $ 4
partial amount1954.00 $
Arts Roma 147.00 $ 8
207.00 $ 0
partial amount354.00 $
Gladiators Neapolis 185.00 $ 3
Roma 725.00 $ 1
partial amount910.00 $
Taxes Olympia 609.00 $ 2
Roma 719.00 $ 9
Carthago 723.00 $ 9
partial amount2051.00 $
full total5269.00 $

Totals for amount and count, without groups.

City Project Amount Count
Carthago Taxes 723.00 $ 9
Neapolis Army 319.00 $ 8
Neapolis Army 964.00 $ 4
Neapolis Gladiators 185.00 $ 3
Olympia Taxes 609.00 $ 2
Roma Army 671.00 $ 5
Roma Arts 147.00 $ 8
Roma Arts 207.00 $ 0
Roma Gladiators 725.00 $ 1
Roma Taxes 719.00 $ 9
5269.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
$723.00 9
Neapolis
Army
$319.00 8
$964.00 4
Army Subtotal $1283.00 12
Gladiators
$185.00 3
Neapolis Subtotal $1468.00 15
Olympia
Taxes
$609.00 2
Roma
Army
$671.00 5
Arts
$147.00 8
$207.00 0
Arts Subtotal $354.00 8
Gladiators
$725.00 1
Taxes
$719.00 9
Roma Subtotal $2469.00 23
Total Across All Categories $5269.00 49