Kbase P121132: How to set a browse column READ-ONLY by column name at run-time?
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  28/05/2010 |
|
Status: Verified
GOAL:
How to set a browse column READ-ONLY by column name at run-time?
GOAL:
How to set a specific column READ-ONLY?
GOAL:
How to set a column READ-ONLY at run-time?
FACT(s) (Environment):
Windows
Progress 9.x
OpenEdge 10.x
OpenEdge Category: Language (4GL/ABL)
FIX:
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.