(Graphical interfaces only)
Creates a dynamic read-only browse widget or a dynamic updatable browse widget. Add browse columns to the widget with the ADD-LIKE-COLUMN, ADD-COLUMNS-FROM, and ADD-CALC-COLUMN methods. Specify the query for the widget with the QUERY attribute.
The dynamic updatable browse can only be a NO-ASSIGN browse—you must make all data assignments to the database.
CREATE BROWSE handle [ IN WIDGET-POOL widget-pool-name ] [ ASSIGN { attribute=expression } ... ] [ trigger-phrase ] |
The following example creates a dynamic browse and adds columns to it:
r-dynbrws.p
/* r-dynbrws */ DEFINE VARIABLE name-hdl AS HANDLE NO-UNDO. DEFINE VARIABLE num-hdl AS HANDLE NO-UNDO. DEFINE VARIABLE address-hdl AS HANDLE NO-UNDO. DEFINE VARIABLE calc-col-hdl AS HANDLE NO-UNDO. DEFINE VARIABLE browse-hdl AS HANDLE NO-UNDO. DEFINE VARIABLE buff-field-hdl AS HANDLE NO-UNDO. DEFINE VARIABLE brws-col-hdl AS HANDLE NO-UNDO. DEFINE VARIABLE jx AS INTEGER NO-UNDO. DEFINE BUTTON btn-delete LABEL "Delete". DEFINE BUTTON btn-quit LABEL "&Quit" AUTO-ENDKEY. DEFINE FRAME MyFrame SKIP(10) btn-delete btn-quit WITH SIZE 80 BY 22. DEFINE QUERY q1 FOR Customer SCROLLING. OPEN QUERY q1 FOR EACH Customer NO-LOCK. CREATE BROWSE browse-hdl ASSIGN TITLE = "Dynamic Browse" FRAME = FRAME MyFrame:HANDLE QUERY = QUERY q1:HANDLE X = 2 Y = 2 WIDTH = 74 DOWN = 10 VISIBLE = YES READ-ONLY = NO SENSITIVE = TRUE. ON ROW-DISPLAY OF browse-hdl DO: IF VALID-HANDLE(calc-col-hdl) THEN calc-col-hdl:SCREEN-VALUE = STRING(Customer.CreditLimit - Customer.Balance). END. ASSIGN num-hdl = browse-hdl:ADD-LIKE-COLUMN("Customer.CustNum"). name-hdl = browse-hdl:ADD-LIKE-COLUMN("Customer.Name"). address-hdl = browse-hdl:ADD-LIKE-COLUMN("Customer.Address"). calc-col-hdl = browse-hdl:ADD-CALC-COLUMN("INT","->,>>>,>>9.99","", "Credit Left"). /* Refresh needs to be done if ADD-CALC-COLUMN is done after the browse is displayed. In ROW-DISPLAY trigger, we can only set the calc field's screen-value if the handle is set. And the handle is set after the ADD-CALC-COLUMN method is done. */ browse-hdl:refresh(). browse-hdl:EXPANDABLE = YES. ON ROW-LEAVE OF browse-hdl DO: IF browse-hdl:CURRENT-ROW-MODIFIED THEN DO: REPEAT jx = 1 TO browse-hdl:NUM-COLUMNS: brws-col-hdl = browse-hdl:GET-BROWSE-COLUMN(jx). IF brws-col-hdl:MODIFIED THEN DO: buff-field-hdl = brws-col-hdl:BUFFER-FIELD. /* If buff-field-hdl is unknown, this is a calculated field and cannot be updated */ IF buff-field-hdl NE ? THEN buff-field-hdl:BUFFER-VALUE = brws-col-hdl:SCREEN-VALUE. END. END. END. END. ON CHOOSE OF btn-delete DO: /* LABEL "DeleteDynBrowse". */ DELETE WIDGET browse-hdl. END. ON CHOOSE OF btn-quit DO: QUIT. END. ENABLE ALL WITH FRAME MyFrame. WAIT-FOR CLOSE OF CURRENT-WINDOW. |
For more information about the WIDGET-ID attribute, see its reference entry in the Handle Attributes and Methods Reference. For more information about the Use Widget ID (-usewidgetid) startup parameter, see OpenEdge Deployment: Startup Command and Parameter Reference.