Kbase P9249: How to assign field values from a local variable to an updatable Smart Data Browse on the CHOOSE of
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  8/11/2005 |
|
Status: Unverified
GOAL:
How to assign field values from a local variable to an updatable Smart Data Browse on the CHOOSE of the ADD button of a smart Panel?
FACT(s) (Environment):
Windows
Progress 9.x
FIX:
In the following example two fields ItemName, Price of the Item table of the Progress Sports2000 sample database are used for illustration.
On the CHOOSE of a windows button, the values to be assigned are captured from the input source using the 'setUserProperty'.
On the CHOOSE of the smart panel?s ADD button these values are assigned through the logic of the VALUE-CHANGED trigger of the browse.
On the CHOOSE of the smart panel?s SAVE button the new values are committed to the database.
1. Add a button to the main window which is used to capture the field values from their source which could be an external device, an OCX etc.
2. Define a UserProperty to store these values on the CHOOSE of the button:
DYNAMIC-FUNCTION('setUserProperty':U IN this-PROCEDURE,
INPUT "cValueList" /* CHARACTER */,
INPUT "Item Name, 1000.95" /* CHARACTER */).
3. Modify the VALUE-CHANGED trigger of the Smart Data Browse as follows:
DO:
{src/adm2/brschnge.i}
IF DYNAMIC-FUNCTION('getNewRecord':U) = "Add" THEN DO:
DEFINE VARIABLE cEnabledFields AS CHARACTER NO-UNDO.
DEFINE VARIABLE hMyFieldHandle AS HANDLE NO-UNDO.
DEFINE VARIABLE cValueList AS CHARACTER NO-UNDO.
DEFINE VARIABLE iCounter AS INTEGER NO-UNDO.
ASSIGN
cValueList = DYNAMIC-FUNCTION('getUserProperty':U IN DYNAMIC-FUNCTION("getContainerSource":U), INPUT "cValueList":U)
cEnabledFields = DYNAMIC-FUNCTION('getFieldHandles':U).
DO iCounter = 1 TO NUM-ENTRIES(cEnabledFields):
hMyFieldHandle = WIDGET-HANDLE(ENTRY(iCounter, cEnabledFields)).
IF hMyFieldHandle:NAME = "ItemName" THEN
ASSIGN
hMyFieldHandle:SCREEN-VALUE = ENTRY(1, cValueList)
hMyFieldHandle:MODIFIED = TRUE.
IF hMyFieldHandle:NAME = "Price" THEN
ASSIGN
hMyFieldHandle:SCREEN-VALUE = ENTRY(2, cValueList)
hMyFieldHandle:MODIFIED = TRUE.
END.
END.
END.