Kbase P35682: How to assign the field screen values in a parent smart data
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  06/08/2003 |
|
Status: Unverified
GOAL:
How to assign the field screen values in a parent smart data viewer located on the main window based on the changes made to those fields in a child viewer located on a smart dialog box?
FACT(s) (Environment):
Windows
FACT(s) (Environment):
Progress 9.x
FIX:
1. Start the AppBuilder and connect to the Sports2000 database.
2. Create a SmartDataObject (SDO) against the customer table to include all the fields except comments and save it as dCustomer2000.w.
3. Create a parent SmartDataViewer (SDV) against the Customer SDO dCustomer2000.w to include all the fields except comments and save it as vCustomer2000.w.
4. Create a child SmartDataViewer (SDV) against the Customer SDO to include some of the fields.
5. Place the following code after the "RUN SUPER" statement in a DisplayFields override procedure of the child SmartDataViewer:
DEFINE VARIABLE c AS CHARACTER NO-UNDO.
DEFINE VARIABLE i AS INTEGER NO-UNDO.
DEFINE VARIABLE h AS HANDLE NO-UNDO.
c = DYNAMIC-FUNCTION('getFieldHandles':U).
DO i = 1 TO NUM-ENTRIES(c):
h = WIDGET-HANDLE(ENTRY(i, c)).
h:SENSITIVE = TRUE.
END.
6. Save the child SmartDataViewer SDV as vCustomer2000c.w.
7. Open a new SmartDialog and drop the child SDV vCustomer2000c.w on it.
8. In the definition section of the SmartDialog add the code:
DEFINE INPUT PARAMETER h_dcustomer2000 AS HANDLE NO-UNDO.
DEFINE INPUT PARAMETER h_vcustomer2000 AS HANDLE NO-UNDO.
9. Place the following code before the "RUN SUPER" statement in an initializeObject override procedure of the SmartDialog:
RUN addLink
( INPUT h_dcustomer2000,
INPUT "DATA",
INPUT h_vcustomer2000c).
RUN addLink
( INPUT h_vcustomer2000c,
INPUT "Update" ,
INPUT h_dcustomer2000).
10. Modify the code in the Window-Close trigger of the SmartDialog to read:
DO:
DEFINE VARIABLE pcChanges AS CHARACTER NO-UNDO.
DEFINE VARIABLE pcInfo AS CHARACTER NO-UNDO.
DEFINE VARIABLE cDisplayedFields AS CHARACTER NO-UNDO.
DEFINE VARIABLE cFieldsHandles AS CHARACTER NO-UNDO.
DEFINE VARIABLE iCounter AS INTEGER NO-UNDO.
DEFINE VARIABLE cFieldName AS CHARACTER NO-UNDO.
DEFINE VARIABLE iPosition AS INTEGER NO-UNDO.
DEFINE VARIABLE hFieldHandle AS HANDLE NO-UNDO.
RUN collectChanges IN h_vCustomer2000c
(INPUT-OUTPUT pcChanges,
INPUT-OUTPUT pcInfo).
ASSIGN
cDisplayedFields = DYNAMIC-FUNCTION('getDisplayedFields':U IN h_vCustomer2000)
cFieldsHandles = DYNAMIC-FUNCTION('getFieldHandles':U IN h_vCustomer2000).
DO iCounter = 1 TO NUM-ENTRIES(pcChanges, CHR(1)) BY 2:
ASSIGN
cFieldName = ENTRY(iCounter, pcChanges, CHR(1))
iPosition = LOOKUP ( cFieldName, cDisplayedFields )
hFieldHandle = WIDGET-HANDLE(ENTRY(iPosition, cFieldsHandles))
hFieldHandle:SCREEN-VALUE = ENTRY(iCounter + 1, pcChanges, CHR(1)).
APPLY 'VALUE-CHANGED' TO hFieldHandle.
END.
APPLY "END-ERROR":U TO SELF.
END.
11. Save the SmartDialog as wDialogViewer.w.
12. Open a new SmartWindow and drop the SDO dCustomer2000.w, the SDV vCustomer2000.w, a SmartToolBar and a button widget on it accepting all the suggested default links.
13. In the definition section of the SmartDialog add the code:
DEFINE INPUT PARAMETER h_dcustomer2000 AS HANDLE NO-UNDO.
DEFINE INPUT PARAMETER h_vcustomer2000 AS HANDLE NO-UNDO.
14. Place the following code in the CHOOSE trigger of the button widget:
RUN wDialogViewer.w (h_dCustomer2000, h_vcustomer2000).
15. Save the SmartWindow as wMain.w.
16. Run wMain.w. Click on the Button. Change some fields on the child viewer of the SmartDialog. Close The Smart Dialog. Notice that the changes are reflected on the parent viewer. The SmartToolBar SAVE, RESET buttons are active to allow either the saving or cancellation of the changes made using the child viewer.