Kbase P100918: How to alternate the color of rows in an ADM2 smartDataBrowse
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  2/9/2005 |
|
Status: Unverified
GOAL:
How to alternate the color of rows in a smartDataBrowse
GOAL:
How to alternate the color of ADM2 smart browse rows by using the CURRENT-RESULT-ROW attribute.
GOAL:
How to avoid error 5906 <attribute> cannot be queried within a ROW-DISPLAY trigger for <browse-widget>. (5906)
FIX:
In order to alternate the color of smartDataBrowse rows you need to manipulate the browse objects query. Ideally this could be done in the ROW-DISPLAY trigger, but there are restrictions as to what can be done in this trigger which result in the error 5906. To resolve the issue and avoid error 5906, the following can be used:
1. Set the smartDataObject OpenOnInit property to false.
2. In the definitions section of the smartDataBrowse add the following local variables:
DEFINE VARIABLE h_columns AS HANDLE NO-UNDO EXTENT 40.
DEFINE VARIABLE h_SDB AS HANDLE NO-UNDO.
DEFINE VARIABLE h_SDO AS HANDLE NO-UNDO.
DEFINE VARIABLE i AS INTEGER NO-UNDO.
3. Create an initializeObject override procedure in the smartDataBrowse and add the following code:
RUN SUPER.
{get browseHandle h_SDB}.
{get datasource h_SDO}.
h_columns[1] = h_SDB:FIRST-COLUMN.
DO i = 2 TO 40:
h_columns[i] = h_columns[i - 1]:NEXT-COLUMN.
IF NOT VALID-HANDLE(h_columns[i]) THEN LEAVE.
END.
ON 'ROW-DISPLAY':U OF h_SDB PERSISTENT RUN showit(h_SDB:QUERY).
DYNAMIC-FUNCTION('openQuery':U IN h_SDO).
4. Create an internal procedure within the smartDataBrowse called "showit" with the following code:
DEFINE INPUT PARAMETER h_query AS HANDLE NO-UNDO.
DEFINE VARIABLE hBuffer AS HANDLE NO-UNDO.
DEFINE VARIABLE hField AS HANDLE NO-UNDO.
DEFINE VARIABLE iBgColour AS INTEGER NO-UNDO.
hBuffer = h_Query:GET-BUFFER-HANDLE(1).
hField = hBuffer:BUFFER-FIELD(1).
IF h_query:CURRENT-RESULT-ROW MODULO 2 = 0 THEN
iBgColour = 11.
ELSE
iBgColour = ?.
DO i = 1 TO 40:
IF NOT VALID-HANDLE(h_columns[i]) THEN LEAVE.
h_columns[i]:BGCOLOR = iBgColour.
END.