Consultor Eletrônico



Kbase P117994: How to change the color of an ADM2 smartDataBrowse column in a Row-Display trigger
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   8/15/2006
Status: Unverified

GOAL:

How to change the color of a smartDataBrowse column, based on the columns value, in a row-display trigger

GOAL:

How to change the color of an ADM2 smart browse column based on its value.

GOAL:

How to avoid error 5906 <attribute> cannot be queried within a ROW-DISPLAY trigger for <browse-widget>. (5906)

FIX:

In order to change the color of smartDataBrowse column based on its value 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 example can be used. In this example the second column in the smartDataBrowse is a customer name field, and it is this field which should be highlighted if it begins with "L":

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(2).
hField = hBuffer:BUFFER-FIELD(2). /* Name is second field in SDO field list and SDB list */

/* If name begins with "L" highlight it */
IF hField:BUFFER-VALUE BEGINS "L" THEN
iBgColour = 11.
ELSE
iBgColour = ?.
IF VALID-HANDLE(h_columns[2]) THEN
h_columns[2]:BGCOLOR = iBgColour.