skip to main content
OpenEdge Development: ADM and SmartObjects
SmartObjects : SmartSelects
 
SmartSelects
A SmartSelect is a special type of SmartDataField that performs a lookup on the associated SmartDataObject field; that is, it retrieves and displays a predefined set of values from which an application user can choose a single value. Inherited SmartDataField behavior ensures that the SmartSelect automatically displays the current field values and that modified SmartSelect values are passed back to the associated SmartDataObject field. Like the basic SmartDataField, the SmartSelect is intended for inclusion only in a SmartDataViewer.
Table 2–13 lists the SmartSelect files.
 
Table 2–13: SmartSelect files 
File type
Filename / SmartLinks
Master file
(Because SmartSelects are customized at design time, a template is not necessary.)
src/adm2/dynselect.w
Primary include file
src/adm2/select.i
ADM/Progress Advisor‑supported SmartLinks
– (None)
Instance property dialog
src/adm2/support/selectd.w (source code)
gui/adm2/support/selectd.r (compiled code)
SmartSelect instance properties
Figure 2–15 shows the default SmartSelect instance properties dialog box (different properties are enabled or disabled if you reset the View as property).
Figure 2–15: SmartSelect Properties dialog box
The instance properties in this dialog box are grouped into the following panes:
*Data Source pane.
*Data pane.
*Properties pane.
*Optional pane.
*Visualization pane.
*Field Attributes pane.
*Geometry pane.
*Define Any Key Trigger on Field pane.
You use these instance properties as described in the following sections.
Data Source pane
You use the instance properties in the Data Source pane to get and specify information about the SmartDataObject that is the data source for the SmartSelect:
*SmartDataObject — This shows the name of the SmartDataObject that serves as the SmartSelect’s data source. This field is populated by dropping a SmartDataObject into the associated SmartDataViewer and linking it to the SmartSelect with a Data SmartLink.
*Filter — This specifies an optional filter for the SmartDataObject; for example, an expression such as the following:
 
CreditLimit > 10000
Note that you can specify the filter only as a hard‑coded value; you cannot specify variables.
*Instance Properties — This opens the instance properties dialog box for the SmartDataObject identified by the SmartDataObject property.
Data pane
You use the instance properties in the Data pane to define the field that the SmartSelect represents:
*External Field — This is a non-updateable field in the SmartDataViewer that displays the SmartDataObject field that the SmartSelect represents. This field is populated when you drop the SmartSelect onto a SmartDataViewer’s field.
*Key Field — This combo box is for specifying the SmartDataObject field that maps to the SmartDataViewer field that the SmartSelect represents. When the SmartSelect’s instance properties dialog box first appears, this property automatically displays any SmartDataObject field whose name matches the name of the SmartDataViewer field.
*Display Field — This combo box is for specifying the SmartDataObject field to display. All the SmartDataObject’s fields are available in the combo box.
*Event on change — Enter an event to PUBLISH if the value of the displayed field changes. For more detailed information on using this property (including an example), see the “Event on change instance property” section.
*Edit Browse Columns — Enter the fields to display in a browse if the View as property is set to Browser. (See the “Visualization pane” section.) If View as is set to Browser and you do not specify any browse columns, the browser displays the key field and the display field. This button is enabled only when the View as property is set to Browser.
Properties pane
You use the instance properties in the Properties pane to specify whether the SmartSelect is enabled and when and how it displays data:
*Enable — If checked (the default), this enables the SmartSelect for use when the containing SmartDataViewer is also enabled for use.
*Display — If this is checked (the default), the SmartSelect displays data when the containing SmartDataViewer is displayed.
*Sort — If checked (the default), this specifies that the SmartSelect data is sorted on the displayed column.
*Exit Browser on Default Action — This field is enabled only when View as is set to Browser. It controls whether the SmartSelect browser exits (closes) when the application user selects a row. If this is unchecked (the default), the browser stays open until it is explicitly closed; otherwise, it exits as soon as the application user selects a row.
*Cancel on Exit of Browse — This field is enabled only when View as is set to Browser. It controls whether exiting (closing) the browser is considered a selection. If this is unchecked (the default), exiting behaves as a selection; otherwise, it does not.
*Reposition Data Source — This controls whether the Data‑Source linked to the SmartDataViewer containing this SmartSelect repositions itself to the record that corresponds with the selected value whenever the value in the SmartSelect changes. If unchecked (the default), the Data‑Source does not reposition itself, otherwise it does reposition itself. The default behavior is the implicit behavior for a browser, so this field is disabled when View as is set to Browser.
Note: Leaving this option unchecked minimizes performance overhead. (The amount of performance overhead varies depending on how much data there is and where it is.) In some circumstances, however, your application will work correctly only if you check this option; for example, if the Data‑Source linked to the containing SmartDataViewer is linked to other objects that must reflect changes in the SmartSelect.
Optional pane
You use the instance properties in the Optional pane to manage the display of no value in the SmartSelect:
*Optional — If checked, this indicates that displaying a value in the SmartSelect is optional. This allows the SmartSelect to display no value (represented by the unknown value).
*No Value — Enter a value to be displayed when no value (the unknown value) is selected. This field is enabled only when Optional is checked.
Visualization pane
You use the instance properties in the Visualization pane to manage the visualization of the SmartSelect:
*View as — A combo box in which to select the type of control used to visualize the SmartSelect. The choices are Browse, Combo-box, Selection-list, and Radio-set.
*If you select Browse, the containing SmartDataViewer displays the SmartSelect as a field with a button that, when pressed by the application user, starts a separate window with a browser that displays the SmartSelect data. This browser shows the number of lines specified by the Inner Lines property and presents the application user with a search field in which to search on the field specified by the Display Field property. (See the “Data pane” section.) The application user selects a row either by double‑clicking or by pressing the RETURN key or its equivalent.
*If you select Combo-box, a radio-set appears from which you can select a combo box type: Drop-down-list, Drop-down, or Simple (the three types of Progress combo boxes).
*If you select Radio-set, a radio set appears from which you can select an orientation: horizontal or vertical.
*Inner Lines — This specifies the number of lines used to display data in the SmartSelect. This option is disabled if you select Radio-set.
Field Attributes pane
You use the instance properties in the Field Attributes pane to specify labeling and formatting information for the SmartSelect field:
*Label, Data Source — The Label fill‑in field displays the label of the SmartSelect field. By default, the AppBuilder uses the label from the data source and disables this field. To enable the Label field so that you can enter your own label, uncheck the associated Data Source check box.
*Browse Label — Enter a title for the browse window if the View as property is set to Browser. (See the “Visualization pane” section.) This field is enabled only when the View as property is set to Browser.
*Data Type — This is the data type of the SmartSelect key field (this field is read only).
*Format, Data Source — The Format fill‑in field displays the format of the SmartSelect key field. By default, the AppBuilder uses the format from the data source and disables this field. To enable the Format field so you can enter your own format, uncheck the associated Data Source check box. This is field is enabled only if you select Combo-box as the value of View as.
*Tooltip — Enter the text of the tooltip for this field. There is no default.
*Help ID — Enter the context ID for the relevant help topic. There is no default.
Geometry pane
You use the instance properties in the Geometry pane to alter the SmartSelect’s size and position. You also can modify the SmartSelect’s geometry by directly manipulating the SmartSelect in the SmartDataViewer Container:
*Width — This is the width of the SmartSelect.
*Height — This is the height of the SmartSelect. This field is disabled for object types that have a fixed height.
*Column — This is the width of the SmartSelect’s field.
*Row — This is the height of the SmartSelect’s field.
Define Any Key Trigger on Field pane
This pane contains the following items:
*Define Any Key Trigger on Field — This field is enabled only when View as is set to Browser. It controls whether a persistent trigger is defined on the ANY-KEY event of the field. If it is checked (the default), the trigger is defined.
The main use for a persistent trigger on the ANY-KEY event is to start the SmartSelect’s browser as specified in the Browse Keys instance property’s fill‑in field. The procedure that runs on this event is the anykey procedure; however, you can have other keys perform actions in the data-source by overriding the anykey procedure in a customized SmartSelect super procedure (adm2/custom/selectcustom.p). For example, you do this to implement combo‑box behavior such as navigation on cursor keys.
See the “Custom class files” section and the “Writing super procedures” section for a description of custom files and information on customizing super procedures, respectively.
*Browse Keys — Specifies the key label or key function that starts the SmartSelect’s browser from the field. You can supply a comma‑separated list.
*Key — A button that opens the Keyboard Event dialog box, shown in Figure 2–16.
Figure 2–16: Keyboard Event dialog box
This dialog box traps a key function or key label and returns the value to the fill‑in field for the Browse Keys instance property. You can append the selected value to the current value by inserting a comma after the existing value before you press the Key button. Note this dialog box cannot distinguish between key functions and key labels.
SmartSelect usage notes
This section discusses special programming considerations for using SmartSelects.
Event on change instance property
The Event on change property allows you to specify an event to PUBLISH if the value of a displayed SmartSelect field changes. Doing this, however, entails more than simply specifying an event name; you also must subscribe the SmartSelect’s data source to your new event, define the event, and so on. The following example illustrates how to do this. It assumes you started the AppBuilder and connected to a copy of the Progress sports2000 database.
To specify an event to PUBLISH if the value of a displayed SmartSelect field changes:
1. Create the following SmartObjects:
*A SmartDataObject named dcust.w against the customer table
*A SmartDataObject named dslsrep.w against salesrep table
*A SmartDataViewer for the customer SmartDataObject. Include the Custnum, Name, and SalesRep fields
2. Drop the salesrep SmartDataObject onto the SmartDataViewer.
3. Drop a SmartSelect onto the salesrep field of the SmartDataViewer.
4. Set the SmartSelect instance properties as follows:
*SmartDataObject: dslsrep.w (the salesrep SmartDataObject)
*Key Field: SalesRep
*Displayed Field: SalesRep
*Event on change: SalesRepSelected (you will define this event in a later step)
*View as: Browser
*Label: Sales Rep
*Browse Title: Sales Representatives
*Tooltip: Select Sales Rep for the Order
For all other instance properties, accept the defaults.
5. In the Section Editor, create the following:
*An override procedure for the SmartDataViewer that uses the initializeObject procedure. Note that whether this procedure runs before or after the SmartDataViewer’s standard behavior depends on where you put the code, as the example code illustrates.
*A SUBSCRIBE statement for your event. (Note that h_dynselect is the SmartSelect object name.)
 
/*-----------------------------------------------------------------
  Purpose:    Super Override
  Parameters:
  Notes:
  -----------------------------------------------------------------*/
 
  /* Code placed here executes PRIOR to the standard behavior. */
 
  RUN SUPER.
 
  /* Code placed here executes AFTER the standard behavior. */
 
  SUBSCRIBE "SalesRepSelected" IN h_dynselect.
 
END PROCEDURE.
6. Using the Section Editor, create an internal procedure that defines your event; for example:
 
/*-------------------------------------------------------------------
  Purpose:
  Parameters:  <none>
  Notes:
  -----------------------------------------------------------------*/
 
DEFINE INPUT PARAMETER cNewValue AS CHARACTER NO-UNDO.
  MESSAGE "VALUE IS: " cNewValue VIEW-AS ALERT-BOX.
END PROCEDURE.
7. Save this procedure with Name = SalesRepSelected.
8. Save the SmartDataViewer object as vcustsls.w.
9. Create a new SmartWindow, then add the following:
*A customer SmartDataObject (dcust.w).
*Your modified SmartDataViewer (vcustsls.w).
*For navigation purposes, a SmartToolbar (accept the defaults).
10. Save this application as the object wcustsls.w, then run it.
11. Choose the Browse icon to view a list of sales‑representative names.
12. Select the name of a sales representative. A dialog box appears and displays the value that you selected. This dialog box is based on the SalesRepSelected procedure you defined.