skip to main content
OpenEdge Development: ADM Reference
Visual Objects and Their Methods and Properties : Methods for SmartDataViewers
 
Methods for SmartDataViewers
This section describes the methods for SmartDataViewers. SmartDataViewers display a single virtual record at a time using a combination of fill-in fields and SmartDataFields.
addRecord
Procedure that initiates the creation of a new record in the RowObject temp-table. Initial values for the new record are displayed in the viewer’s frame. Keeps a running total of the records added.
Location: viewer.p
Parameters: None
Notes:  
*addRow() is invoked in the update target, which creates the new RowObject temp-table record and returns the column values. When the SmartDataViewer is a GroupAssign target, its GroupAssign source has already added the record, therefore only the values of the columns are retrieved.
*Column values are passed to displayFields, which displays the values in the viewer’s frame.
*The record is not actually created in the database until it is committed. This is done in assignDBRow procedure.
*For Add and Copy, it is important that key fields, and any other fields assigned by the CREATE trigger, not be set to updateable in the SmartDataObject and enabled for data entry. If they are, the screen values are assigned on top of the key values set by the trigger, with an error as the likely result.
*applyEntry is run to apply entry to the first field in the frame after the initial column values are displayed.
*The procedure submitForeignKey in data.p automatically assigns key values inherited as ForeignField values from another SmartDataObject. For example, in an Order SmartDataViewer used for adding new Orders for the current Customer selected in another object, the CustNum field can (and normally should) be left disabled in the Order SmartDataViewer. Its value is assigned in the Order SmartDataObject to the CustNum value from the parent Customer SmartDataObject at the time the new record is Saved. You can override submitForeignKey in the SmartDataObject your Data visualization object is connected to in order to write any additional special logic you want to apply when adding or copying a record.
*addRecord is invoked when an Add is initiated, typically by choosing the Add button in an Update SmartPanel, or the Add button or Add menu item in a SmartToolbar.
*addRecord republishes the addRecord event to handle the Add for GroupAssign targets.
*addRecord can be customized when additional processing is needed at the start of an Add operation. Keep in mind that when an addRecord override is invoked, the new record has not yet been created, and there is no transaction active.
cancelRecord
Procedure that cancels an Update, Add, or Copy operation.
Location: viewer.p
Parameters: None
Notes:  
*When you choose the Cancel button during:
*Add or Copy — The new record is erased and the previously current record is redisplayed.
*Update — The Update is cancelled and the record’s original values are redisplayed.
*cancelRecord is invoked when an update is cancelled, usually by choosing the Cancel button in an Update SmartPanel or the Cancel button or Cancel menu item in a SmartToolbar.
*cancelRecord republishes the “cancelRecord” event to handle the cancel for GroupAssign targets.
*cancelRecord can be customized when additional processing is needed when a record Add, Copy, or Update is canceled. You might want to do this to restore other related nondatabase fields or other objects to their original values, or to undo some action that was taken when the Add, Copy, or Update was initiated.
copyRecord
Procedure that initiates creation of a new record starting with a copy of the previously displayed record.
Location: viewer.p
Parameters: None
Notes:  
*copyRecord displays the previously displayed record’s values and allows data entry. The new record is not actually created until it is committed in serverCommit. See the addRecord reference entry for additional notes.
*copyRow() is invoked in the update target, which creates the new RowObject temp-table record and copies the current row to it.
*copyRecord is invoked when a Copy operation is initiated, usually by choosing the Copy button from an Update SmartPanel or the Copy button or Copy menu item from a SmartToolbar.
*copyRecord republishes the “copyRecord” event to handle the Copy operation for any GroupAssign targets.
*copyRecord can be customized when a Copy operation needs special processing.
disableFields
Procedure that disables the fields in a list represented by the AppBuilder generated preprocessor value {&ENABLED–FIELDS}.
Location: viewer.p
Parameters:  
INPUT pcFieldType AS CHARACTER
Can have values of All or Create.
Notes:  
*disableFields is invoked when a SmartDataViewer’s RowObject fields are to be disabled without disabling other fields or variables in the viewer.
*The ENABLED–FIELDS preprocessor value contains a list of RowObject fields that are enabled in a SmartDataViewer. At initialization time, this is turned into the EnabledHandles property, which stores a list of the widget handles of the enabled fields in the SmartDataViewer’s frame, allowing efficient access to them.
*The pcFieldType parameter can have a value of All or Create. This allows disabling of all the fields or only fields that were used to create (add/copy) a new record. The Create option is not yet supported.
*disableFields re-publishes the disableFields event to disable fields in any GroupAssign targets.
*When a field in the list is a SmartObject itself (for example, a SmartField object), disableField is run in the SmartObject to disable it.
*For editor fields, READ–ONLY is turned on rather than making the field insensitive since editors need to be sensitive for scrolling.
*disableFields can be customized when you require additional processing when RowObject fields are disabled. You might want to do this to disable or hide other widgets not associated with RowObject fields.
displayFields
Procedure that displays the current row values by moving them to the viewer’s frame screen-values.
Location: viewer.p
Parameters:  
INPUT pcColValues AS CHARACTER
CHR(1)‑delimited list of the STRING–VALUEs of the requested columns; the first value of this list is the RowIdent value of the corresponding record to be displayed.
Notes:  
*The pcColValues input parameter contains the field values to be displayed in the SmartDataViewer.
*displayFields is invoked from resetRecord, cancelRecord, copyRecord, addRecord, and from dataAvailable when the data source has a new row.
*displayFields runs displayObjects to display values for nondatabase-related fields.
*When a field is a SmartObject itself (for example, a SmartField object), setDataValue is invoked in the SmartObject to set its value.
*No RowObject record is available in a SmartDataViewer, so a customization of displayFields cannot refer to the RowObject buffer. You can use the colValues function to access a list of column values from the Viewer’s SmartDataObject if needed, or the columnStringValue function can return the formatted value of a particular field.
Examples:  
PROCEDURE displayFields:
/* ----------------------------------------------------------------------
   Purpose:   Super Override
              This SmartDataViewer gets the handle of its container. If this
              is a window, then the title of the window is changed to reflect
              the current record.
   Parameters:
   Notes:
-------------------------------------------------------------------------*/
  DEFINE INPUT PARAMETER pcColValues AS CHARACTER NO-UNDO.
  DEFINE VARIABLE hContainerSource   AS HANDLE    NO-UNDO.
 
  /* Code placed here will execute PRIOR to standard behavior. */
  hContainerSource = DYNAMIC-FUNCTION(’linkProperty’:U,
                     INPUT ’Container-Source’:U, INPUT ’ContainerHandle’:U).
  RUN SUPER(INPUT pcColValues).
  /* Code placed here will execute AFTER standard behavior.*/
 
  hContainerSource:TITLE = "Customer : " + 
    RowObject.NAME:SCREEN-VALUE IN FRAME {&FRAME-NAME}
    WHEN VALID-HANDLE(hContainerSource) 
      AND ContainerSource:TYPE = ’WINDOW’:U.
END PROCEDURE.
 
PROCEDURE displayFields:
/*------------------------------------------------------------------------
Purpose:      Super Override
              If the value of the country field is ’France’ in this
              SmartDataViewer, then make the background color of this field
              red.  Otherwise leave it the its default color.
  Parameters:
  Notes:
------------------------------------------------------------------------*/
  DEFINE INPUT PARAMETER pcColValues AS CHARACTER NO-UNDO.
  
/* Code placed here will execute PRIOR to standard behavior.  */
  RUN SUPER( INPUT pcColValues).
  /* Code placed here will execute AFTER standard behavior.     */
 
  RowObject.Country:BGCOLOR IN FRAME {&FRAME-NAME} = 
    IF RowObject.Country:SCREEN-VALUE = ’France’ THEN 12 ELSE ?.
END PROCEDURE.
enableFields
Procedure that enables fields in the ENABLED-FIELDS list AppBuilder generated preprocessor.
Location: viewer.p
Parameters: None
Notes:  
*When the frame field is a SmartObject (for example, a SmartField), enableField is run in the SmartObject.The ENABLED–FIELDS preprocessor value contains a list of RowObject fields that are enabled in a SmartDataViewer. At object initialization, this is turned into the EnabledHandles property, which holds a list of the widget handles of the enabled fields in the SmartDataViewer’s frame, for efficient access.
*If no TableIO–Source (or GroupAssign–Source connected to a TableIO–Source for SmartDataViewers) is present or no record is available, the fields are not enabled.
*enableFields republishes the enableFields event to handle enabling fields in any GroupAssign targets.
*enableFields can be customized when you require additional processing when RowObject fields are enabled. You might want to do this to enable or hide other widgets not associated with RowObject fields.
fieldModified
Event procedure that handles the setting of DataModified when a field has changed in the datavisual (viewer or browser) object. The setting for DataModified is determined by the setting specified for the ModifyFields property.
Location: viewer.p
Parameters:  
INPUT phField AS HANDLE
Handle of a field whose value has changed.
Notes:  
*By default, DataModified is set to TRUE. For informaton about changing the default, see the “ModifyFields” section property.
*The passed field must be in the list of EnabledFields or EnabledObjFlds.
*This procedure is called from valueChanged, DataModified of the SmartDataField, or the Client APIs that change widget values.
*Returns TRUE if this change triggers a DataModified change. For example, this is the first change in the object.
initializeObject
Procedure that enables fields in the list represented by the AppBuilder generated preprocessor value {&ENABLED–FIELDS}.
Location: viewer.p
Parameters: None
Notes:  
*The ENABLED–FIELDS preprocessor value contains a list of RowObject fields that are enabled in a SmartDataViewer. At object initialization, this is turned into the EnabledHandles property, which holds a list of the widget handles of the enabled fields in the SmartDataViewer’s frame, for efficient access.
*If no TableIO–Source (or GroupAssign–Source connected to a TableIO–Source for SmartDataViewers) is present or no record is available, the fields are not enabled.
*enableFields republishes the “enableFields” event to handle enabling fields in any GroupAssign targets.
*enableFields can be customized when you require additional processing when RowObject fields are enabled. You might want to do this to enable or hide other widgets not associated with RowObject fields.
toolbar
Toolbar event handler procedure that handles the cases OK and Cancel.
Location: viewer.p
Parameters:  
INPUT pcValue AS CHARACTER
Valid values are OK and Cancel.
Notes: None
updateState
Procedure that initializes code specific to SmartDataViewers.
Location: viewer.p
Parameters: None
Notes:  
*initializeObject reads through the list of enabled and displayed fields and gets their handles to store in the FieldHandles and EnabledHandles properties.
*dataAvailable is invoked to check to see if the data-source already has a record available for display.
If there is an Update–Target and a TableIO–Source in Save mode, or if this is part of a GroupAssign and the GroupAssign–Source is already enabled, enableFields is invoked to enable fields in the ENABLED–FIELDS list.
valueChanged
Procedure that defines the persistent event handler of the value-changed event of the frame. This handler is important to how a viewer and browser sets DataModified to TRUE. Because all field-level objects value-changed events are also managed by this procedure, it calls fieldModified to set DataModified to TRUE based on the setting for the ModifyFields property.
Location: viewer.p
Parameters: None
Notes:  
*Static objects can reach this also by applying U10 event to run it.
*See the “ModifyFields” section for more information.
viewRecord
Procedure that sets object in viewMode.
Location: viewer.p
Parameters: None
Notes: None