Progress
ADM 2 Guide


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. However, doing this entails more than simply specifying an event name; you must also subscribe the SmartSelect’s data source to your new event, define the event, and so forth. The following example illustrates how to do this. Note that it assumes that you have started the AppBuilder and connected to a copy of the Progress sports2000 database. Follow these steps:

  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:
  7. /*-------------------------------------------------------------------
      Purpose:
      Parameters:  <none>
      Notes:
      -----------------------------------------------------------------*/
    
    DEFINE INPUT PARAMETER cNewValue AS CHARACTER NO-UNDO.
      MESSAGE "VALUE IS: " cNewValue VIEW-AS ALERT-BOX.
    END PROCEDURE. 
    

  8. Save this procedure with Name = SalesRepSelected.
  9. Save the SmartDataViewer object as vcustsls.w.
  10. 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)
  11. Save this application as the object wcustsls.w, then run it.
  12. Choose Browse icon to view a list of sales-representative names.
  13. 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 that you defined.

Copyright © 2004 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095