View source
City Project Amount Count
Carthago Army 596.00 $ 0
Taxes 192.00 $ 0
Neapolis Army 334.00 $ 3
Arts 242.00 $ 8
Arts 676.00 $ 8
Gladiators 19.00 $ 2
Olympia Army 119.00 $ 1
Gladiators 901.00 $ 0
Roma Arts 653.00 $ 3
Taxes 950.00 $ 2

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 Army 596.00 $ 0
Taxes 192.00 $ 0
Carthago subtotal788.00 $0
Neapolis Army 334.00 $ 3
Arts 242.00 $ 8
Arts 676.00 $ 8
Gladiators 19.00 $ 2
Neapolis subtotal1271.00 $21
Olympia Army 119.00 $ 1
Gladiators 901.00 $ 0
Olympia subtotal1020.00 $1
Roma Arts 653.00 $ 3
Taxes 950.00 $ 2
Roma subtotal1603.00 $5
Total4682.00 $27

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

Project City Amount Count
Army Olympia 119.00 $ 1
Neapolis 334.00 $ 3
Carthago 596.00 $ 0
partial amount1049.00 $
Arts Neapolis 242.00 $ 8
Roma 653.00 $ 3
Neapolis 676.00 $ 8
partial amount1571.00 $
Gladiators Neapolis 19.00 $ 2
Olympia 901.00 $ 0
partial amount920.00 $
Taxes Carthago 192.00 $ 0
Roma 950.00 $ 2
partial amount1142.00 $
full total4682.00 $

Totals for amount and count, without groups.

City Project Amount Count
Carthago Army 596.00 $ 0
Carthago Taxes 192.00 $ 0
Neapolis Army 334.00 $ 3
Neapolis Arts 242.00 $ 8
Neapolis Arts 676.00 $ 8
Neapolis Gladiators 19.00 $ 2
Olympia Army 119.00 $ 1
Olympia Gladiators 901.00 $ 0
Roma Arts 653.00 $ 3
Roma Taxes 950.00 $ 2
4682.00 $27

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
Army
$596.00 0
Taxes
$192.00 0
Carthago Subtotal $788.00 0
Neapolis
Army
$334.00 3
Arts
$242.00 8
$676.00 8
Arts Subtotal $918.00 16
Gladiators
$19.00 2
Neapolis Subtotal $1271.00 21
Olympia
Army
$119.00 1
Gladiators
$901.00 0
Olympia Subtotal $1020.00 1
Roma
Arts
$653.00 3
Taxes
$950.00 2
Roma Subtotal $1603.00 5
Total Across All Categories $4682.00 27