Consultor Eletrônico



Kbase P150151: 4GL/ABL: How to change the color on alternate rows of a codejock ReportControl report?
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   7/24/2009
Status: Unverified

GOAL:

4GL/ABL: How to change the color on alternate rows of a codejock ReportControl report?

GOAL:

How to set the ForeColor and the BackColor Properties of the codejock ReportControl ReportRecordItem Object?

GOAL:

How to add fields and records to the CodeJock ReportControl and populate the report?

FACT(s) (Environment):

Windows
OpenEdge 10.x

FIX:

The following procedure illustrates, how to add fields and records to the CodeJock ReportControl and populate the report. Also, it shows how set the BackColor of a row at runtime. The same syntax may be used to change the ForeColor Property of a ReportRecordItem:
PROCEDURE pFillReportControlRows:
DEFINE INPUT PARAMETER hTable AS HANDLE NO-UNDO.
DEFINE VARIABLE hQuery AS HANDLE NO-UNDO.
DEFINE VARIABLE iCounter AS INTEGER NO-UNDO.
DEFINE VARIABLE hNewRecord AS COM-HANDLE NO-UNDO.
DEFINE VARIABLE hNewField AS COM-HANDLE NO-UNDO.
DEFINE VARIABLE iRowNum AS INTEGER NO-UNDO.

/* Add the data to the report control */
CREATE QUERY hQuery.
hQuery:SET-BUFFERS(hTable).
hQuery:QUERY-PREPARE("FOR EACH ttData NO-LOCK INDEXED-REPOSITION":U).
hQuery:QUERY-OPEN.
/* Create the ReportControl rows and fields from the dynamic query */
REPEAT:
hQuery:GET-NEXT.
IF hQuery:QUERY-OFF-END THEN LEAVE.
/* Add a record and increment the number of records by one */
ASSIGN
hNewRecord = chCtrlFrame:ReportControl:Records:ADD()
iRowNum = iRowNum + 1.
/* Assign the data to the rows fields and color them based on whether the record number is odd or even*/
/* The decimal value 8388564 is the Aquamarine color in the RGB table */
/* The decimal value 12211667 is the Medium Orchid color in the RGB table */
DO iCounter = 1 TO hTable:NUM-FIELDS:
ASSIGN
hNewField = hNewRecord:AddItem(hTable:BUFFER-FIELD(iCounter):BUFFER-VALUE)
hNewField:BackColor = IF iRowNum MODULO 2 = 0 THEN 8388564 ELSE 12211667.
END. /* DO iCounter */
END. /* REPEAT: */
hQuery:QUERY-CLOSE.
/* Apply changes to ReportControl */
chCtrlFrame:ReportControl:Populate().
/* Fit column width to contents (allways AFTER populate method)*/
DO iCounter = (chCtrlFrame:ReportControl:COLUMNS:COUNT - 1) TO 0 BY -1:
chCtrlFrame:ReportControl:Columns(iCounter):BestFit().
END.
/* Release all objects */
IF VALID-HANDLE(hQuery) THEN DELETE OBJECT hQuery.
IF VALID-HANDLE(hTable) THEN DELETE OBJECT hTable.
IF VALID-HANDLE(hNewRecord) THEN RELEASE OBJECT hNewRecord.
IF VALID-HANDLE(hNewField) THEN RELEASE OBJECT hNewField.
ASSIGN
hQuery = ?
&.nbsp; hTable = ?
hNewRecord = ?
hNewField = ?.
END PROCEDURE..