Consultor Eletrônico



Kbase 21984: Making a Particular Updatable Column in a Browse Read-Only
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   4/19/2002
SUMMARY:

This Solution applies to Progress 9.x. It shows how to enable/disable a particular column into a browse. The column must be in the "ENABLE" fields list when the browse is defined.

SOLUTION:

1) Get the browse handle and the column name.

In order to make an updateable column read-only, you need the handle of the browse and the column name.

You can get the browse handle with:

hB = BROWSE brname:HANDLE.

In particular, for a Smart Browse the handle is:

hB = BROWSE {&BROWSE-NAME}:HANDLE.

2) Set the column to READ-ONLY.

The following procedure will make the column READ-ONLY.

PROCEDURE disableColumn:
DEFINE INPUT PARAMETER hB AS HANDLE.
DEFINE INPUT PARAMETER cColName AS CHARACTER.

DEF VAR hC AS HANDLE.
DEF VAR vi AS INTEGER.
hC = hb:FIRST-COLUMN.
DO vi = 1 TO hB:NUM-COLUMNS :
IF hC:NAME = cColName THEN DO:
/* this will make the column READ-ONLY */
IF NOT hc:READ-ONLY THEN hc:READ-ONLY = TRUE.
RETURN.
END.
hC = hC:NEXT-COLUMN.
END.
END PROCEDURE.

3) Re-enable the column.

Then to re-enable the column we need a similar code:

PROCEDURE enableColumn:
DEFINE INPUT PARAMETER hB AS HANDLE.
DEFINE INPUT PARAMETER cColName AS CHARACTER.

DEF VAR hC AS HANDLE.
DEF VAR vi AS INTEGER.
hC = hb:FIRST-COLUMN.
DO vi = 1 TO hB:NUM-COLUMNS :
IF hC:NAME = cColName THEN DO:
/* this will make the column UPDATABLE */
IF hc:READ-ONLY THEN hc:READ-ONLY = FALSE.
RETURN.
END.
hC = hC:NEXT-COLUMN.
END.
END PROCEDURE.