Progress
Language Tutorial
for Character
Using the Browse Widget
The data widgets you’ve used so far represent a single variable or database field. The browse widget goes beyond that and represents the results list of a defined query. Basically, you can think of a browse widget as a selection list of database records. Instead of listing a single value on each line of the list, browse widgets let you list values from several fields.
You can use a browse widget to display or update record values. When you use a browse for display only, it is called a read-only browse. Figure 8–19 describes the parts of a read-only browse widget.
Figure 8–19: Parts of a Read-only Browse Widget
![]()
When you use a browse to let the user view and update record values, it is called an updatable browse. Figure 8–20 describes the parts of an updatable browse widget.
Figure 8–20: Parts of an Updatable Browse Widget
![]()
Like the other widgets you’ve used so far, the browse widget is a screen object. You can manipulate the browse widget in many of the same ways you manipulate the other widgets. The browse widget is a ready-made navigable interface to a query.
You can update the form you’ve built in this chapter by replacing the navigation buttons with an updatable browse widget, as shown in Figure 8–21.
Figure 8–21: Database Access Form with a Browse Widget
![]()
To completely understand browse widgets, you need to understand how to work with the screen object and how to work with the associated query.
NOTE: Keep these points in mind when using the browse widget:
- The type of row marker indicator that displays can vary depending on the platform on which you are running the Progress character client.
- The mouse cannot be used to select and access records from either a read-only or an updatable browse widget when the browse widget is displayed in character client mode on Windows platforms. You must use the keyboard features.
The syntax for a browse widget looks like a DISPLAY statement with a frame phrase attached, but it’s not. The browse widget mimics the syntax of the DISPLAY statement because it is intuitive and employs many of the same concepts. This is a partial syntax for defining a browse widget.
Table 8–3 defines some of the elements of the DEFINE BROWSE statement syntax.
Read-only Browse
A read-only browse is a good mechanism for viewing records without allowing any changes. When you click anywhere in a row, Progress selects that row.
Updatable Browse
An updatable browse is a good mechanism for applying changes to your data. You can add, delete and update records with an updatable browse. The capabilities of the updatable browse are very similar to those of a spreadsheet application. You can view and update records at the same time.
To select a row in an updatable browse widget, click on the row marker on the left side of the browse. When you click a cell in a row, Progress enters edit mode for that cell if you have enabled the column for input. When the browse enters edit mode, Progress executes a ROW-ENTRY event. When you move focus away from that row, Progress executes a ROW-LEAVE event followed by a VALUE-CHANGED event, and writes any changes to the database.
To define an updatable browse, use the browse-enable-phrase of the DEFINE BROWSE statement. You can enable one to all the columns in a browse for input with the ENABLE option. Remember not to allow changes to a unique index, such as Cust-Num or Item-Num.
Browse Control Keys
Table 8–4 summarizes the control keys that are specially defined for the browse.
Table 8–4: Browse Control Keys
Key Function Common
Keyboard
Mappings on Windows
Description (Space Bar)1 (Space Bar) Edit mode:
Enters a space or zeroes numeric data in the focused cell.Row mode:
Fires the VALUE-CHANGED event. ¨ Edit Mode:
Moves the cursor one character to the left in the cell.
(Does not leave the cell.)Row mode:
Scrolls the browser widget horizontally one column to the left.![]()
Edit mode:
Moves the cursor one character to the right in the cell.
(Does not leave the cell.)Row mode:
Scrolls the browser widget horizontally one column to the right. Ø Edit mode:
Moves focus down to the next cell in the column.Row mode:
Moves focus down one row. ¦ Edit mode:
Moves focus up to the previous cell in the column.Row mode:
Moves focus up one row. Edit mode:
Moves focus to the previous enabled cell in the browse
(right to left; bottom to top).Row mode:
No function. Edit mode:
Moves focus to the next enabled cell in the browse
(left to right; top to bottom).Row mode:
No function. Edit mode:
Moves focus to the last cell in the current column.Row mode:
Moves focus to the last row in the browse widget. Edit mode:
Moves focus to the first cell in the current column.Row mode:
Moves focus to the first row in the browse widget. Edit mode:
Pages down one full page of data.Row mode:
Pages down one full page of data. Edit mode:
Pages up one full page of data.Row mode:
Pages up one full page of data. Edit mode:
Changes the browser to row mode, with selection set to the currently focused row.Row mode:
Changes the browser to edit mode and places focus in the first enabled cell
of the currently focused row.If you define the browse with the NO-ROW-MARKERS option, REPLACE has no effect. Edit mode:
Moves focus to the next cell in the current column.Row mode-Fires the DEFAULT-ACTION event. Always leaves the browse widget and sets input focus to the next sibling widget of the browse in the tab order.
Working with the Query
A query associated with a browse widget must be defined with the SCROLLING option.
When you open a query, Progress automatically fills the browse. When you reopen the query, Progress refreshes the browse with the latest data.
If a query is associated with a browse, do not use the GET statement with that query. If you do, the browse might get out of sync with the query.
Browse Events
An enabled browse widget accepts many events. The browse:
- Accepts input focus by way of the navigation key functions (such as TAB) or the mouse.
- Responds to the universal key functions (such as GO or HELP).
- Moves input focus among the records with the arrow keys.
- Responds to ENTRY, LEAVE, and VALUE-CHANGED triggers.
- Responds to SCROLL-NOTIFY triggers.
- Responds to HOME and END triggers.
The browse widget supports the following column-level events:
- ENTRY — Occurs when the user enters the named column in the focused row.
- LEAVE — Occurs when the user leaves the named column in the focused row.
- START-SEARCH — Occurs when the user chooses a column label and enters search mode.
- END-SEARCH — Occurs when the user selects a row or starts to edit a browse cell after a START-SEARCH has occurred.
The browse widget also supports the following row-level events:
Deleting a Row in an Updatable Browse
When you delete a row from an updatable browse widget, you must perform two distinct steps to complete the record deletion. First, reread the record with an EXCLUSIVE-LOCK and use the DELETE statement to remove the record from the database. Next, use the DELETE-SELECTED-ROWS( ) method to delete the record from the browse widget and the query results list.
It is important to remember that when you delete a row from a browse using the DELETE-SELECTED-ROWS( ) method, you are not deleting the record from the database. The DELETE-SELECTED-ROWS( ) method deletes the record from the results list, but the record is still in the database. Make sure that you remove a record from all sources when you delete a browse row.
Browse Programming Example
In this example, the complete database access form developed so far is modified to use a browse widget.
- Open
lt-08-07.p
and run it. The Database Access Form appears.- Select an item using the row marker to the left of the row.
- Click on a cell other than the Item Number. Make a change in the Item-Name, Price, On-hand, or Cat-Description field.
- Move focus to another row. Notice that Progress saved your changes to the updated field.
- Choose Exit, then press SPACEBAR to return to the Procedure Editor.
Here is the first section of code for the new form:
These notes explain the highlights of the first part of the programming example:
- To use a browse with a query, include the SCROLLING option on the DEFINE QUERY statement.
- This statement defines the browse widget, the fields it displays, and the number of rows it shows at one time. The ENABLE option defines this as an updatable browse where all fields except Item-Num can be changed.
- These statements define the widgets and frames for the procedure.
- This statement defines the trigger for button btn-Add.
Here is the second section of code for the new form:
These notes explain the highlights of the second half of the programming example.
- This DO statement executes when changing focus from a row in browse Item-Browse. For new records, the IF...THEN statement updates the browse.
- The INPUT BROWSE option of the ASSIGN statement writes the new information to the database.
- The CREATE-RESULT-LIST-ENTRY( ) method updates the query results list to match the browse and database.
- This statement displays the Item-Num assigned to a new record by the database.
- This DELETE trigger on button btn-Delete deletes the selected rows.
Column Searching
Read-only browse widgets employ single-character searches on the first column of the browse. That means that if the user presses an alphanumeric key, the browse moves focus to the next row where the first column begins with that letter or number.
Updatable browse widgets employ the same kind of single-character search, but on any column. When the user selects a column label, Progress enters search mode for that column. When the user presses an alphanumeric key, the browse moves focus to the next row where the selected column begins with that letter or number.
You can override the default searching behavior to implement incremental searching in updatable browse widgets. See the browse widget chapter in the Progress Programming Handbook for information on how to add this feature to your application.
Other Browse Techniques
The following list contains some of the techniques you can implement to make your browse more useable. See the chapter on using the browse widget in the Progress Programming Handbook for more information about how to use these features.
Copyright © 2004 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |