Feedback
 
Did this article resolve your question/issue?

   

Your feedback is appreciated.

Please tell us how we can make this article more useful. Please provide us a way to contact you, should we need clarification on the feedback provided or if you need further assistance.

Characters Remaining: 1025

 


Article

How to ENABLE/DISABLE browse fields at runtime

« Go Back

Information

 
Article Number000014150
EnvironmentProduct: Progress
Version: 8.x, 9.x
Product: OpenEdge
Version: 10.x, 11.x
OS: Windows
Question/Problem Description
How to ENABLE/DISABLE a BROWSE widget fields ( columns) at will during runtime?
How to get a BROWSE widget and a BROWSE COLUMN handles?
How to set the READ-ONLY attribute of a BROWSE COLUMN  at run time?
Is there way to delete a column from a browse at Run-Time?
 
Steps to Reproduce
Clarifying Information
Error Message
Defect/Enhancement Number
Cause
Resolution

To enable/disable a browse column for input at runtime, use the READ-ONLY attribute of the browse column.
Attached SamplewWin.w demonstrates this. It requires a connection to a sports2000 database to run.

The key section is in the 
 VALUE-CHANGED trigger of the cbSelectAction COMBO-BOX widget:
 

DO:
    DEFINE VARIABLE hBrowse  AS HANDLE     NO-UNDO.
    DEFINE VARIABLE hColumn  AS HANDLE     NO-UNDO.
    DEFINE VARIABLE iCounter AS INTEGER    NO-UNDO.

    /* Get the handle of the Browse widget */
    ASSIGN
        hBrowse = BROWSE   BROWSE-1:HANDLE.

     /* Get the handle of the selected field column */
    DO iCounter = 1 TO hBrowse:NUM-COLUMNS:
        hColumn = hBrowse:GET-BROWSE-COLUMN(iCounter).
        IF hColumn:NAME = cbSelectField:SCREEN-VALUE THEN LEAVE.
    END.

    /* Apply the selected action on the selected field */
    CASE cbSelectAction:SCREEN-VALUE:
        WHEN "Enable Field" THEN DO:
            hColumn:READ-ONLY = FALSE.
            MESSAGE "The " hColumn:NAME " was enabled as requested."
                VIEW-AS ALERT-BOX INFO BUTTONS OK.
        END.
        WHEN "Disable Field" THEN DO:
            hColumn:READ-ONLY = TRUE.
            MESSAGE "The " hColumn:NAME " was disabled as requested."
                VIEW-AS ALERT-BOX INFO BUTTONS OK.
        END.
        OTHERWISE
            MESSAGE "No action specified...No action taken."
                VIEW-AS ALERT-BOX INFO BUTTONS OK.
    END CASE.
END.

While the sample was built using the GUI AppBuilder, it will also run in a ChUI character client.
Workaround
Notes
Only the fields initially listed in the ENABLE phrase of the DEFINE BROWSE definition may be manipulated in this fashion at runtime
In AppBuilder generated code: The fields must be included in the browse-enable-phrase / must be enabled in the Column Editor dialog via the browse's property sheet.

Variations:
  • To enable or disable the entire browse, apply the action to the browse handle rather than using the browse handle to navigate tot the field handles.
  • This code can be used anywhere a specified condition is detected; the condition may or may not be a VALUE-CHANGED event as in this example.
Attachment
Last Modified Date9/13/2015 3:10 AM