PreviousNextIndex

DEFINE BROWSE statement

Defines and creates either a read-only or updateable browse widget that is created at compile time for use in one or more procedures, or within a single class.

Note: Does not apply to SpeedScript programming.
Syntax

DEFINE { [ [ NEW ] SHARED ] | [ PRIVATE ] } 
  BROWSE browse-name 
  QUERY query-name   
    [ SHARE-LOCK | EXCLUSIVE-LOCK | NO-LOCK ] [ NO-WAIT ]  
  DISPLAY 
    { column-list | record [ EXCEPT field ... ] }  
    [ browse-enable-phrase ]  
    { browse-options-phrase } 
    [ CONTEXT-HELP-ID expression ] 
    [ DROP-TARGET ] 
    [ TOOLTIP tooltip ] 

NEW SHARED BROWSE browse-name
SHARED BROWSE browse-name
[ PRIVATE ] BROWSE browse-name
BROWSE browse-name
QUERY query-name
[ SHARE-LOCK | EXCLUSIVE-LOCK | NO-LOCK ]
NO-WAIT
DISPLAY column-list
expression
column-format-phrase
WIDTH n
@base-field
view-as-phrase
DISPLAY record
EXCEPT field . . .
browse-enable-phrase
HELP string
VALIDATE ( condition, msg-expression )
AUTO-RETURN
DISABLE-AUTO-ZAP
browse-options-phrase
[ constant ] DOWN [ WIDTH width ]
size-phrase
FGCOLOR expression
BGCOLOR expression
DCOLOR expression
PFCOLOR expression
LABEL-FONT constant
LABEL-DCOLOR expression
LABEL-FGCOLOR expression
LABEL-BGCOLOR expression
[ MULTIPLE | SINGLE ]
[ SEPARATORS | NO-SEPARATORS ]
NO-ASSIGN
NO-ROW-MARKERS
NO-LABELS
NO-BOX
FONT constant
title-phrase
NO-VALIDATE
NO-SCROLLBAR-VERTICAL | SCROLLBAR-VERTICAL
ROW-HEIGHT-CHARS | ROW-HEIGHT-PIXELS row-height
FIT-LAST-COLUMN
EXPANDABLE
NO-EMPTY-SPACE
NO-AUTO-VALIDATE
CONTEXT-HELP-ID expression
DROP-TARGET
TOOLTIP tooltip
Examples

This procedure sets up a read-only browse widget for the Customer table. The browse displays the CustNum and Name fields. A separate frame, f2, displays more information on the currently chosen Customer.

r-browse.p
DEFINE QUERY q1 FOR Customer.  
DEFINE BROWSE b1 QUERY q1 DISPLAY CustNum Name  
  WITH 17 DOWN TITLE "Customer Browse". 
DEFINE FRAME f1 b1 
  WITH SIDE-LABELS AT ROW 2 COLUMN 2. 
DEFINE FRAME f2 
  WITH 1 COLUMNS AT ROW 2 COLUMN 38. 
ON VALUE-CHANGED OF b1 DO: 
  DISPLAY Customer EXCEPT Customer.Comments WITH FRAME f2. 
END. 
  
OPEN QUERY q1 FOR EACH Customer. 
ENABLE b1 WITH FRAME f1. 
APPLY "VALUE-CHANGED" TO BROWSE b1. 
WAIT-FOR WINDOW-CLOSE OF CURRENT-WINDOW. 

The VALUE-CHANGED event occurs each time the user selects a row within the browse widget. The associated database record is automatically placed into the record buffer. The trigger on the VALUE-CHANGED event displays that record in frame f2.

The APPLY statement causes the first Customer record to display before the user selects a record.

The second example sets up an updateable browse that displays some fields from the Customer table. Select a row marker to select a row. Select a cell to edit it. Select a column label to initiate a search. (The trigger on ROW-LEAVE is only necessary because the NO-ASSIGN option prevents automatic commitment of the data when the user leaves a row.)

r-brows2.p
DEFINE VARIABLE method-return AS LOGICAL NO-UNDO. 
DEFINE QUERY q1 FOR Customer SCROLLING. 
DEFINE BROWSE b1 QUERY q1 NO-LOCK DISPLAY Customer.CustNum Customer.Name  
  Customer.Phone ENABLE Customer.Name Customer.Phone  
  WITH 15 DOWN NO-ASSIGN SEPARATORS. 
DEFINE BUTTON button1 LABEL "New Row". 
DEFINE FRAME f1  
  SKIP(1) SPACE(8) b1 SKIP(1) SPACE(8) button1 
  WITH NO-BOX. 
ON ROW-LEAVE OF b1 IN FRAME f1 DO: /* No-Assign Browser */ 
  /* If new row, create record and assign values in browse. */ 
  IF b1:NEW-ROW THEN DO: 
    CREATE Customer. 
    ASSIGN INPUT BROWSE b1 Customer.Name Customer.Phone. 
    DISPLAY Customer.CustNum WITH BROWSE b1. 
    method-return = b1:CREATE-RESULT-LIST-ENTRY(). 
    RETURN. 
  END. 
  /* If record exists and was changed in browse, update it. */ 
  IF BROWSE b1:CURRENT-ROW-MODIFIED THEN DO: 
    GET CURRENT q1 EXCLUSIVE-LOCK. 
    IF CURRENT-CHANGED Customer THEN DO: 
      MESSAGE "This record has been changed by another user." SKIP 
        "Please re-enter your changes.". 
      DISPLAY Customer.CustNum Customer.Name Customer.Phone WITH BROWSE b1. 
      RETURN NO-APPLY. 
    END. 
    ELSE /* Record is the same, so update it with exclusive-lock */ 
      ASSIGN INPUT BROWSE b1 Customer.Name Customer.Phone. 
      /* Downgrade the lock to a no-lock. */ 
      GET CURRENT q1 NO-LOCK. 
  END. 
END. 
ON CHOOSE OF button1 IN FRAME f1 DO: /* Insert */ 
  method-return = b1:INSERT-ROW("AFTER"). 
END. 
OPEN QUERY q1 FOR EACH Customer. 
ENABLE ALL WITH FRAME f1. 
WAIT-FOR WINDOW-CLOSE OF CURRENT-WINDOW 

Notes
See also

ADD-CALC-COLUMN( ) method, ADD-COLUMNS-FROM( ) method, ADD-LIKE-COLUMN( ) method, Class-based data member access, CLOSE QUERY statement, CREATE BROWSE statement, CURRENT-CHANGED function, CURRENT-RESULT-ROW function, DEFINE QUERY statement, DISPLAY statement, FIND statement, FORM statement, Format phrase, Frame phrase, GET statement, NUM-RESULTS function, OPEN QUERY statement, RUN statement


OpenEdge Release 10.2B
Copyright © 2009 Progress Software Corporation
PreviousNextIndex