Consultor Eletrônico



Kbase 20859: How to Change the Format of a Browse Column at Runtime?
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   1/25/2005
Status: Verified

GOAL:

How to have the same browse display certain columns in varying formats without the need to redesign the entire browse?

GOAL:

How to Change the Format of a Browse Column at Runtime?

FACT(s) (Environment):

Progress 8.x
Progress 9.x
OpenEdge 10

CAUSE:

You can store the format of a given column in a variable and thus change the format of a browse column by assigning the format value of choice to that variable.

NOTE: The following code example is for informational purposes only. It exploits the browse cell FORMAT attribute and the SCROLL-NOTIFY browse event. The solution is not applicable to character based clients because browse cell FORMAT attribute is supported only on windows.

FIX:

In this solution, assume you are connected to the Progress sample Sports database, and that you have a regular browse based on the customer table. Further assume that this browse includes the customer balance and that you need to display the balance column using a format assigned to the character variable cFormatVariable.
Follow these steps:

1) Insert the following statement in the main block of the code
immediately after the "RUN enable_UI statement":

APPLY 'SCROLL-NOTIFY' TO {&BROWSE-NAME}.

2) Create the following trigger:

ON SCROLL-NOTIFY OF BROWSE-1 IN FRAME DEFAULT-FRAME
DO:
DEFINE VARIABLE cFormatVariable AS CHARACTER NO-UNDO.
DEFINE VARIABLE iCountVariable AS INTEGER NO-UNDO.

ASSIGN cFormatVariable = "999,999,999.999".

DO iCountVariable = 1 TO {&BROWSE-NAME}:NUM-ITERATIONS:
{&BROWSE-NAME}:SELECT-ROW(iCountVariable).
Balance:FORMAT IN BROWSE {&BROWSE-NAME} = cFormatVariable.
Balance:WIDTH-CHARS IN BROWSE {&BROWSE-NAME} =

LENGTH(cFormatVariable) + 1.
END.
END.

NOTES:

- In the above code, after you reset the format of the balance field. make sure that the width of the balance column is wide enough to accommodate the new format.

- Since the WIDTH-CHARS attribute is not settable in Version 8.3B, the statement that ivolves this attribute causes a syntax error in that version.

The solution is still valid for 8.3B (without this statement) provided that the browse is originally designed to accomodate the new width of the column.