View source
City Project Amount Count
Carthago Army 741.00 $ 6
Gladiators 536.00 $ 7
Gladiators 629.00 $ 4
Neapolis Gladiators 84.00 $ 4
Taxes 621.00 $ 0
Olympia Army 132.00 $ 6
Army 874.00 $ 5
Army 885.00 $ 4
Taxes 206.00 $ 9
Roma Arts 272.00 $ 3

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 741.00 $ 6
Gladiators 536.00 $ 7
Gladiators 629.00 $ 4
Carthago subtotal1906.00 $17
Neapolis Gladiators 84.00 $ 4
Taxes 621.00 $ 0
Neapolis subtotal705.00 $4
Olympia Army 132.00 $ 6
Army 874.00 $ 5
Army 885.00 $ 4
Taxes 206.00 $ 9
Olympia subtotal2097.00 $24
Roma Arts 272.00 $ 3
Roma subtotal272.00 $3
Total4980.00 $48

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

Project City Amount Count
Army Olympia 132.00 $ 6
Carthago 741.00 $ 6
Olympia 874.00 $ 5
885.00 $ 4
partial amount2632.00 $
Arts Roma 272.00 $ 3
partial amount272.00 $
Gladiators Neapolis 84.00 $ 4
Carthago 536.00 $ 7
629.00 $ 4
partial amount1249.00 $
Taxes Olympia 206.00 $ 9
Neapolis 621.00 $ 0
partial amount827.00 $
full total4980.00 $

Totals for amount and count, without groups.

City Project Amount Count
Carthago Army 741.00 $ 6
Carthago Gladiators 536.00 $ 7
Carthago Gladiators 629.00 $ 4
Neapolis Gladiators 84.00 $ 4
Neapolis Taxes 621.00 $ 0
Olympia Army 132.00 $ 6
Olympia Army 874.00 $ 5
Olympia Army 885.00 $ 4
Olympia Taxes 206.00 $ 9
Roma Arts 272.00 $ 3
4980.00 $48

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
$741.00 6
Gladiators
$536.00 7
$629.00 4
Gladiators Subtotal $1165.00 11
Carthago Subtotal $1906.00 17
Neapolis
Gladiators
$84.00 4
Taxes
$621.00 0
Neapolis Subtotal $705.00 4
Olympia
Army
$132.00 6
$874.00 5
$885.00 4
Army Subtotal $1891.00 15
Taxes
$206.00 9
Olympia Subtotal $2097.00 24
Roma
Arts
$272.00 3
Total Across All Categories $4980.00 48