View source
City Project Amount Count
Carthago Arts 785.00 $ 6
Arts 957.00 $ 3
Neapolis Army 222.00 $ 3
Army 496.00 $ 8
Taxes 70.00 $ 7
Taxes 99.00 $ 8
Olympia Arts 352.00 $ 8
Arts 766.00 $ 0
Roma Army 829.00 $ 2
Arts 162.00 $ 5

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 Arts 785.00 $ 6
Arts 957.00 $ 3
Carthago subtotal1742.00 $9
Neapolis Army 222.00 $ 3
Army 496.00 $ 8
Taxes 70.00 $ 7
Taxes 99.00 $ 8
Neapolis subtotal887.00 $26
Olympia Arts 352.00 $ 8
Arts 766.00 $ 0
Olympia subtotal1118.00 $8
Roma Army 829.00 $ 2
Arts 162.00 $ 5
Roma subtotal991.00 $7
Total4738.00 $50

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

Project City Amount Count
Army Neapolis 222.00 $ 3
496.00 $ 8
Roma 829.00 $ 2
partial amount1547.00 $
Arts Roma 162.00 $ 5
Olympia 352.00 $ 8
766.00 $ 0
Carthago 785.00 $ 6
957.00 $ 3
partial amount3022.00 $
Taxes Neapolis 70.00 $ 7
99.00 $ 8
partial amount169.00 $
full total4738.00 $

Totals for amount and count, without groups.

City Project Amount Count
Carthago Arts 785.00 $ 6
Carthago Arts 957.00 $ 3
Neapolis Army 222.00 $ 3
Neapolis Army 496.00 $ 8
Neapolis Taxes 70.00 $ 7
Neapolis Taxes 99.00 $ 8
Olympia Arts 352.00 $ 8
Olympia Arts 766.00 $ 0
Roma Army 829.00 $ 2
Roma Arts 162.00 $ 5
4738.00 $50

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
Arts
$785.00 6
$957.00 3
Arts Subtotal $1742.00 9
Carthago Subtotal $1742.00 9
Neapolis
Army
$222.00 3
$496.00 8
Army Subtotal $718.00 11
Taxes
$70.00 7
$99.00 8
Taxes Subtotal $169.00 15
Neapolis Subtotal $887.00 26
Olympia
Arts
$352.00 8
$766.00 0
Arts Subtotal $1118.00 8
Olympia Subtotal $1118.00 8
Roma
Army
$829.00 2
Arts
$162.00 5
Roma Subtotal $991.00 7
Total Across All Categories $4738.00 50