View source
City Project Amount Count
Carthago Taxes 472.00 $ 8
Taxes 869.00 $ 7
Neapolis Taxes 374.00 $ 5
Olympia Army 289.00 $ 5
Gladiators 524.00 $ 0
Taxes 759.00 $ 0
Roma Army 125.00 $ 1
Arts 520.00 $ 9
Gladiators 411.00 $ 6
Gladiators 520.00 $ 4

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 472.00 $ 8
Taxes 869.00 $ 7
Carthago subtotal1341.00 $15
Neapolis Taxes 374.00 $ 5
Neapolis subtotal374.00 $5
Olympia Army 289.00 $ 5
Gladiators 524.00 $ 0
Taxes 759.00 $ 0
Olympia subtotal1572.00 $5
Roma Army 125.00 $ 1
Arts 520.00 $ 9
Gladiators 411.00 $ 6
Gladiators 520.00 $ 4
Roma subtotal1576.00 $20
Total4863.00 $45

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

Project City Amount Count
Army Roma 125.00 $ 1
Olympia 289.00 $ 5
partial amount414.00 $
Arts Roma 520.00 $ 9
partial amount520.00 $
Gladiators Roma 411.00 $ 6
520.00 $ 4
Olympia 524.00 $ 0
partial amount1455.00 $
Taxes Neapolis 374.00 $ 5
Carthago 472.00 $ 8
Olympia 759.00 $ 0
Carthago 869.00 $ 7
partial amount2474.00 $
full total4863.00 $

Totals for amount and count, without groups.

City Project Amount Count
Carthago Taxes 472.00 $ 8
Carthago Taxes 869.00 $ 7
Neapolis Taxes 374.00 $ 5
Olympia Army 289.00 $ 5
Olympia Gladiators 524.00 $ 0
Olympia Taxes 759.00 $ 0
Roma Army 125.00 $ 1
Roma Arts 520.00 $ 9
Roma Gladiators 411.00 $ 6
Roma Gladiators 520.00 $ 4
4863.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
Taxes
$472.00 8
$869.00 7
Taxes Subtotal $1341.00 15
Carthago Subtotal $1341.00 15
Neapolis
Taxes
$374.00 5
Olympia
Army
$289.00 5
Gladiators
$524.00 0
Taxes
$759.00 0
Olympia Subtotal $1572.00 5
Roma
Army
$125.00 1
Arts
$520.00 9
Gladiators
$411.00 6
$520.00 4
Gladiators Subtotal $931.00 10
Roma Subtotal $1576.00 20
Total Across All Categories $4863.00 45