Summary lines in tables
Table views can display a summary line, to show aggregate values for columns.
To get a summary line in a table, define aggregate field item tags at the bottom of the
TABLE
container, with the corresponding AGGREGATE
form item
definitions in the ATTRIBUTES
section.
Define the type of the aggregate field with the AGGREGATETYPE
attribute: The
aggregate value can be automatically computed, or set by program.
To get a global label for the summary line, specify the AGGREGATETEXT
attribute at the
TABLE
level. This aggregate label will appear on the left in the summary line, if
no aggregate text is defined at the aggregate field level.
To decorate the summary line, use presentation style attributes such as summaryLineAlwaysAtBottom
.
LAYOUT
TABLE
{
[c1 |c2 |c3 ]
[c1 |c2 |c3 ]
[c1 |c2 |c3 ]
[c1 |c2 |c3 ]
[grt |tot ]
}
END
END
ATTRIBUTES
EDIT c1 = FORMONLY.pkey, TITLE="Num";
EDIT c2 = FORMONLY.name, TITLE="Name";
EDIT c3 = FORMONLY.price, TITLE="Price";
AGGREGATE grt = FORMONLY.o_great,
AGGREGATETEXT = "Greatest: ",
AGGREGATETYPE = MAX;
AGGREGATE tot = FORMONLY.o_total,
AGGREGATETEXT = "Total: ",
AGGREGATETYPE = SUM;
END
INSTRUCTIONS
SCREEN RECORD sr(FORMONLY.pkey THRU FORMONLY.price);
END
DISPLAY ARRAY
:MAIN
DEFINE arr DYNAMIC ARRAY OF RECORD
pkey INT,
name VARCHAR(20),
price DECIMAL(10,2)
END RECORD
DEFINE x INT
FOR x=1 TO 50
LET arr[x].pkey = 100+x
LET arr[x].name = SFMT("item%1",x)
LET arr[x].price = (3.45 * x) + (1.23 * (x MOD 2))
END FOR
OPEN FORM f1 FROM "form"
DISPLAY FORM f1
DISPLAY ARRAY arr TO sr.* ATTRIBUTES(UNBUFFERED)
END MAIN
For more details, see Aggregate fields.