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
NEW SHARED BROWSEbrowse-name
SHARED BROWSEbrowse-name
[ PRIVATE ] BROWSEbrowse-name
Defines and identifies a browse widget as a class-scoped object. A class-scoped handle-based object is not a member of a class, but provides a resource that is privately available to the class definition similar to a non-shared data element in a procedure definition. The option to specify the PRIVATE access mode is provided for readability. You cannot specify PRIVATE when defining a browse widget as a data element in a method or procedure.Note: This option is applicable only when defining a class-scoped browse widget in a class definition (.cls
) file.BROWSEbrowse-name
QUERYquery-name
[ SHARE-LOCK | EXCLUSIVE-LOCK | NO-LOCK ]NO-WAITDISPLAYcolumn-list
expression
column-format-phrase
Specifies the format for a value displayed in the browse. Thecolumn-format-phrase
is a subset of the Format phrase.
WIDTHn
Specify a width for the browse column.n
represents a multiplier of the average character width of the column font. Specifying a width smaller than the format string creates a scrolling browse cell, if the column is updateable.For more information on FORMAT strings and label options, see the Format phrase reference entry. The column and label color and font options work like those specified in thebrowse-options-phrase
. If color or fonts are specified with this phrase, they only affect the specific column and override similar options specified in thebrowse-options-phrase
.@base-field
Thebase-field
must be the name of a field or variable; it cannot be an expression or constant.The AVM reserves enough space for thebase-field
to hold the longest format displayed there. All right-justified fields (numeric fields that do not use side labels) are right justified within the reserved area.
To determine the format to use for displaying the expression at thebase-field
, the AVM looks at the following and uses the first format that applies:
- An explicit format used with the
expression.
- If the expression is a character string constant, a format that accommodates that string.
- If the data type of the expression matches that of the
base-field
, the format of thebase-field.
- The standard format of the expression as if it were displayed without a
base-field.
view-as-phrase
Specifies the type of widget to use for displaying values in the browse column. This is theview-as-phrase
syntax, which is a subset of the VIEW-AS phrase:
If you do not specify aview-as-phrase
, the widget type for the browse column will be a FILL-IN, by default.For more information, see the VIEW-AS phrase reference entry.DISPLAYrecord
Specifies the record you want to display. If you specify a record, all fields from the record are displayed unless you use the EXCEPT option to eliminate specific fields.See the Record phrase reference entry for more information.EXCEPTfield
. . .browse-enable-phrase
Specifies which fields in thecolumn-list
are enabled for input.
List each field or variable from thecolumn-list
that you want enabled. Specify ALL to specify every item in thecolumn-list
. Use the EXCEPT option to exclude specific items when you use the ALL option.For each field or variable, you can also specify custom help and validation, as shown in the next two entries.HELPstring
VALIDATE (condition
,msg-expression
)
Specifies an expression against which you want to validate the data entered in a browse cell. Thecondition
is a Boolean expression (a constant, field name, variable name, or expression) whose value is TRUE or FALSE.When you use the VALIDATE option to validate a specific cell, any reference to that cell incondition
is assumed to be the new input value. For example, in thebrowse-enable phrase
below, the PromiseDate that is compared to the OrderDate is the new user input, not the existing data:
To validate a new value against another new value, use the INPUT qualifier, as shown:
If the value ofcondition
is FALSE, usemsg-expression
to display a specific message. You must enclosemsg-expression
in quotation marks ("").The AVM processes validation criteria whenever the user attempts to leave the browse cell. If the cell value is not valid, the AVM displaysmsg-expression
in the message area, causes the terminal to beep, and does not advance out of the browse cell.If the user tabs to a cell, makes no changes, and leaves the cell, the AVM does not process the validation criteria specified with the VALIDATE option until you press GO (F1). If the user presses ENDKEY or END-ERROR, or an error occurs, the AVM does not test the validation criteria specified with the VALIDATE option.If the input source for the procedure is a table, the AVM validates each input field (except those with a value of "-"). If the result of the validation is FALSE,msg-expression
is displayed and the AVM treats the validation as an error.To suppress the Data Dictionary validation criteria for a cell, use this VALIDATE option:
AUTO-RETURNDISABLE-AUTO-ZAPbrowse-options-phrase
Specifies options that affect the browse widget as a whole. The options affect both the layout and the function of the browse widget. Note that you cannot include aggregate-phrases (such as TOTAL, MIN, etc.) in this phrase. This is the syntax forbrowse-options-phrase
:
[constant
] DOWN [ WIDTHwidth
]size-phrase
Specifies the outer size of the browse border. When this option is used instead of the DOWN option, the AVM determines the number of rows that can be displayed in the browse. Following is the syntax forsize-phrase
:
For more information onsize-phrase
, see the SIZE phrase reference entry.Abrowse-options-phrase
must contain a DOWN option (optionally with a WIDTH option) or asize-phrase
.FGCOLORexpression
BGCOLORexpression
DCOLORexpression
PFCOLORexpression
LABEL-FONTconstant
LABEL-DCOLORexpression
LABEL-FGCOLORexpression
LABEL-BGCOLORexpression
[ MULTIPLE | SINGLE ][ SEPARATORS | NO-SEPARATORS ]NO-ASSIGN
Disables automatic writes on new data in an updateable browse. If this option is not specified, data entered into an updateable browse is assigned on any action that results in a ROW-LEAVE event. This option is intended for use with user-defined triggers on the ROW-LEAVE event. Essentially, when this option is specified, you must make all data assignments by way of the updateable browse.
In the above example, the code looks for a special case where automatic database writes are not desirable and prevents them. The body of the trigger handles other processing before proceeding to commit the changes. First the trigger refinds the current Customer record and then uses the CURRENT-CHANGED function to see if it has changed while the user was updating the browse cells. If it has not changed, the changes are committed. If it has changed, the trigger would handle that condition, too.Note that an ASSIGN statement with the INPUT BROWSE option can be mixed with other assignment types, as shown:
NO-ROW-MARKERSNO-LABELSNO-BOX
Does not display a box around the browse. If you do not use this option, the AVM displays a box around the data you are displaying.If you are sending data to a device other than a terminal and you do not use this option, the AVM omits the sides and bottom line of the box and replaces the top line with blanks.FONTconstant
title-phrase
Displays a title as part of the top line of the box around the browse. For example:
Thetitle-string
is a constant, field name, variable name, or expression whose result is a character value. Theexpression
is the value you want to display as a title. Iftitle-string
is a constant character string, it must be surrounded by quotes (""). The AVM automatically centerstitle-string
in the top line of the browse box.You can use the DCOLOR option to specify the color of the title under a character user interface.You cannot specify the title color or font of a browse in a graphical interface.NO-VALIDATENO-SCROLLBAR-VERTICAL | SCROLLBAR-VERTICALROW-HEIGHT-CHARS | ROW-HEIGHT-PIXELSrow-height
FIT-LAST-COLUMN
Allows the browse to be displayed so that there is no empty space to the right and no horizontal scroll bar by potentially widening or shrinking the last browse column’s width.This option applies to graphical interfaces only.When this option is specified, and the last browse column can be fully or partially displayed in the browse’s viewport, then the last browse column’s width is adjusted so that it fits within the viewport with no empty space to its right and no horizontal scroll bar.If the last browse column is fully contained in the viewport with empty space to its right, it grows so that its right edge is adjacent to the vertical scroll bar.If the last browse column extends outside the viewport, it shrinks so its right edge is adjacent to the vertical scroll bar and the horizontal scroll bar is not needed.The default value is FALSE.Note: The FIT-LAST-COLUMN option performs the same function as the EXPANDABLE option. Progress Software Corporation recommends that you use the FIT-LAST-COLUMN option instead of the EXPANDABLE option. This recommendation includes replacing EXPANDABLE with FIT-LAST-COLUMN in your current code.EXPANDABLE
If you set a browse’s EXPANDABLE option to TRUE, the AVM extends the right-most browse column horizontally to the browse’s right edge, if necessary, to cover any white space that might appear there — unless you explicitly set the width of the right-most browse column using the WIDTH-CHARS or WIDTH-PIXELS option. The expansion of the right-most browse column might occur anytime the browse or another browse column is resized.The right-most browse column expands only when there is no horizontal scroll bar. This is because when there is a horizontal scroll bar, no white space appears between the right edge of the right-most browse column and the right edge of the browse.Note: The EXPANDABLE option performs the same function as the FIT-LAST-COLUMN option. Progress Software Corporation recommends that you use the FIT-LAST-COLUMN option instead of the EXPANDABLE option. This recommendation includes replacing EXPANDABLE with FIT-LAST-COLUMN in your current code.NO-EMPTY-SPACE
Allows the browse to display with no empty space to the right and no horizontal scroll bar.You cannot specify both NO-EMPTY-SPACE and FIT-LAST-COLUMN for the DEFINE BROWSE statement. If you specify both, the compiler displays an error message. If you set either the NO-EMPTY-SPACE option or the DEFINE BROWSE option to TRUE and one of them is already TRUE, a warning message displays at run time.NO-AUTO-VALIDATECONTEXT-HELP-IDexpression
DROP-TARGETTOOLTIPtooltip
Allows you to define a help text message for a browse widget. The AVM automatically displays this text when the user pauses the mouse pointer over a browse widget for which a ToolTip is defined. You can add or change the TOOLTIP option at any time.If TOOLTIP is set to "" or the Unknown value (?
), then the ToolTip is removed from the browse. No ToolTip is the default. ToolTips are supported in Windows only.ExamplesThis 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.
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.)
Notes
- You cannot define a SHARED or NEW SHARED browse widget in a persistent procedure. If you do, ABL raises ERROR on the RUN statement that creates the procedure.
- You cannot define a SHARED or NEW SHARED browse widget in a class definition (
.cls
) file. If you do, ABL generates a compilation error.- The vertical scrollbar is displayed with the browse by default in Windows interfaces. It may be removed by setting the SCROLLBAR-VERTICAL attribute to FALSE or by specifying NO-SCROLLBAR-VERTICAL in the DEFINE BROWSE statement. If the horizontal scrollbar is needed, it is provided by default.
- The vertical scrollbar thumb size reflects the percentage of rows that are displayed in the viewport relative to the number of rows in the results list. If all the rows have not yet been read into the results list, the AVM uses the MAX-DATA-GUESS attribute to estimate the total size.
- You must put the browse into a frame on the same procedure level on which the browse is defined. For example, you cannot define a browse in an outer procedure and then display it in a frame defined within an internal procedure.
- You cannot display a browse widget in a down frame. The AVM automatically converts any frame containing a browse to a 1 down frame.
- You can modify the field values displayed in the current iteration of a browse by using the WITH BROWSE option of the DISPLAY statement. For example:
- The browse widget has built-in support for the HOME, END, PAGE-UP, and PAGE-DOWN key functions.
- You can specify an application-defined widget ID for a compile-time defined browse widget using the
form-item
phrase in either the FORM statement or the DEFINE FRAME statement. See the FORM statement and DEFINE FRAME statement reference entries for more information.- ABL treats the query associated with a browse as a scrolling query. You do not have to specify SCROLLING in the DEFINE QUERY statement.
- When you execute an OPEN QUERY or REPOSITION statement for the query associated with the browse, the browse is automatically adjusted to remain in sync with the query. However, when you execute a GET statement, the browse is not adjusted. You can use the GET statement to perform background processing without affecting the browse, but you must execute a REPOSITION statement to put the query and browse back in sync.
- The record locking behavior specified for a query in the DEFINE BROWSE statement overrides the record locking behavior specified with the OPEN QUERY statement. The default record locking behavior of a browse widget is NO-LOCK. The default record locking behavior of a query defined with the OPEN QUERY statement is SHARE-LOCK. If you define a query and a browse widget for the query without explicitly defining record locking behavior, the query will have the NO-LOCK behavior.
- For an updateable browse, the AVM re-gets the record with a SHARE-LOCK when the user first edits a row, if it initially has a NO-LOCK. The user then can make changes to the updateable cells in the row. When the user leaves a row with changes (moves to a new row or another widget), the AVM starts a transaction and gets the record with EXCLUSIVE-LOCK and NO-WAIT. If the AVM gets the record, the record is updated, the record is disconnected (removes the lock), the transaction ends, and the lock is downgraded to its original status. If the get record with EXCLUSIVE-LOCK fails, the transaction is backed out, an error message is displayed, and focus remains with the edited browse row with the changed data. To redisplay the original data, use the DISPLAY...WITH BROWSE statement.
- All LEAVE triggers for a browse row execute before the row changes are committed. If the LEAVE trigger returns a NO-APPLY, the changes are not committed.
- It is also possible to use an updateable browse to add new records and delete old ones.
- Browse widgets in Windows have user search capabilities. Special events allow you to extend these capabilities.
- To select more than one row in a browse widget, press CTRL and then click on the rows you want to select.
- When an updateable browse enters edit mode, all selected records are deselected. Essentially, a browse in edit mode ignores multiple selections.
- The ADD-CALC-COLUMN, ADD-COLUMNS-FROM and ADD-LIKE-COLUMN methods may be used on a compile-time defined browse to add a dynamic browse column. If a dynamic browse column in a compile-time defined browse is made updateable, the browse is changed to a NO-ASSIGN browse and you become responsible for any database update associated with it.
- The browse’s QUERY attribute can now be set to the Unknown value (
?
). If this is done, all browse columns are removed.- The browse’s QUERY attribute can now be changed to any query. Previously, the new query had to have the same underlying fields as the original query. If the new query is different, all browse columns are removed. You must specify new columns with the ADD-CALC-COLUMN, ADD-COLUMNS-FROM, and ADD-LIKE-COLUMN methods.
See alsoADD-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
|