TRGroup

Fuente: source/classes/rgroup.prg

Standalone class

TRGroup defines a group break within a TReport. Groups enable hierarchical reports with group headers, footers, and automatic subtotals. When a group break occurs (detected by a change in the group expression value), the group footer is printed, totals are reset, and the group header for the new group is printed on the next page or following line.

Key DATA Members

DATATypeDescription
oReportObjectParent TReport object
aTotalArrayArray of accumulated subtotal values per column
bGroupCodeblockGroup expression; evaluated each row to detect breaks
bHeaderCodeblockHeader text codeblock, printed when a new group starts
bFooterCodeblockFooter text codeblock, printed when a group ends
cValueCharacterCurrent group value
cOldValueCharacterPrevious group value, used for break detection
nCounterNumericRow count within the current group
lEjectLogicalEject page when group breaks
lHeaderLogicalHas a header to print
lFooterLogicalHas a footer to print

Methods

MethodDescription
New( bGroup, bHeader, bFooter, bFont, lEject, oReport )Create a new TRGroup definition
Header( nRow )Render the group header at the specified row
Footer( nRow )Render the group footer at the specified row
Total( nRow )Render column subtotals at the specified row
Check()Returns .T. if the group value has changed (break occurred)
Evaluate()Increment the group row counter
Reset()Reset totals, counter, and current/old values
Stabilize( nOrder )Calculate header/footer dimensions

Example: Group by State with Subtotals

#include "FiveWin.ch"
#include "report.ch"

function GroupedReport()

   local oReport

   REPORT oReport TITLE "Sales by State" PREVIEW

   GROUPS oReport

   GROUP ON { || oSale:State } ;
          HEADER { || "State: " + oSale:State } ;
          FOOTER { || "Subtotal for " + oSale:State }

   COLUMN TITLE "Customer" DATA { || oSale:Customer }
   COLUMN TITLE "Amount"   DATA { || oSale:Amount } ;
          PICTURE "9,999.99" TOTAL

   END REPORT

   ACTIVATE REPORT oReport

return nil

Notes

Ver También