View source
City Project Amount Count
Carthago Gladiators 648.00 $ 4
Taxes 232.00 $ 3
Neapolis Army 135.00 $ 3
Army 274.00 $ 8
Army 453.00 $ 0
Gladiators 471.00 $ 5
Gladiators 541.00 $ 4
Olympia Army 23.00 $ 7
Army 614.00 $ 2
Army 823.00 $ 1

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 648.00 $ 4
Taxes 232.00 $ 3
Carthago subtotal880.00 $7
Neapolis Army 135.00 $ 3
Army 274.00 $ 8
Army 453.00 $ 0
Gladiators 471.00 $ 5
Gladiators 541.00 $ 4
Neapolis subtotal1874.00 $20
Olympia Army 23.00 $ 7
Army 614.00 $ 2
Army 823.00 $ 1
Olympia subtotal1460.00 $10
Total4214.00 $37

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

Project City Amount Count
Army Olympia 23.00 $ 7
Neapolis 135.00 $ 3
274.00 $ 8
453.00 $ 0
Olympia 614.00 $ 2
823.00 $ 1
partial amount2322.00 $
Gladiators Neapolis 471.00 $ 5
541.00 $ 4
Carthago 648.00 $ 4
partial amount1660.00 $
Taxes Carthago 232.00 $ 3
partial amount232.00 $
full total4214.00 $

Totals for amount and count, without groups.

City Project Amount Count
Carthago Gladiators 648.00 $ 4
Carthago Taxes 232.00 $ 3
Neapolis Army 135.00 $ 3
Neapolis Army 274.00 $ 8
Neapolis Army 453.00 $ 0
Neapolis Gladiators 471.00 $ 5
Neapolis Gladiators 541.00 $ 4
Olympia Army 23.00 $ 7
Olympia Army 614.00 $ 2
Olympia Army 823.00 $ 1
4214.00 $37

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
$648.00 4
Taxes
$232.00 3
Carthago Subtotal $880.00 7
Neapolis
Army
$135.00 3
$274.00 8
$453.00 0
Army Subtotal $862.00 11
Gladiators
$471.00 5
$541.00 4
Gladiators Subtotal $1012.00 9
Neapolis Subtotal $1874.00 20
Olympia
Army
$23.00 7
$614.00 2
$823.00 1
Army Subtotal $1460.00 10
Olympia Subtotal $1460.00 10
Total Across All Categories $4214.00 37