Kbase 18931: ADM2 - How To Get Data From A Child SmartObject
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  10/16/2008 |
|
Status: Unverified
GOAL:
How to retrieve data from a SmartObject that is a child of some other SmartObject (i.e. the child SmartObject is nested within the parent SmartObject).
FACT(s) (Environment):
Progress 9.x
SYMPTOM(s):
ADM2
FIX:
The steps that follow show how to retrieve the contents of two fields
on a SmartDataViewer from a SmartWindow.
These assumptions are in effect:
- You have a SmartWindow which has the following SmartObjects nested inside of it:
a) SmartDataObject
b) SmartDataBrowser
c) SmartDataViewer
d) SmartUpdatePanel
- You want to get the values of two fields from the SmartDataViewer when a button is clicked in the SmartWindow (the button was placed directly on the SmartWindow).
- The SmartObjects listed in #1 have already been created (but have not had any code added to them).
- The SmartDataViewer is named vData.w.
1) In the SmartWindow do the following:
a) Add this code to the Definitions section:
DEFINE VARIABLE var1 AS CHARACTER NO-UNDO.
DEFINE VARIABLE var2 AS DECIMAL NO-UNDO.
b) Add the following code to the CHOOSE event of the button:
ASSIGN var1 = DYNAMIC-FUNCTION('getFieldA' IN h_vdata)
var2 = DYNAMIC-FUNCTION('getFieldB' IN h_vdata).
MESSAGE 'var1 (Field-A in SDV) = ' var1 SKIP
'var2 (Field-B in SDV) = ' STRING(var2)
VIEW-AS ALERT-BOX.
c) Save the SmartWindow.
2) In the SmartDataViewer do the following:
a) Add a field, call it Field-A and make its data type character.
b) Add a field, call it Field-B and make its data type decimal.
c) Add a user defined function called getFieldA() and make its return type character.
d) Add the following code to the getFieldA() function:
RETURN Field-A:SCREEN-VALUE IN FRAME {&FRAME-NAME}.
e) Add a user defined function called getFieldB() and make its return type decimal.
f) Add the following code to the getFieldB() function:
RETURN DECIMAL(Field-B:SCREEN-VALUE IN FRAME {&FRAME-NAME}).
g) Save the SmartDataViewer.
3) Run the SmartWindow.
4) Type any data into Field-A and Field-B on the SmartDataViewer.
5) Click the button in the SmartWindow.
At this point a message box will be displayed that shows the values entered into these two fields on the SmartDataViewer.