Kbase P15788: How to access the SCREEN-VALUE of a SmartDataViewer on the CHOOSE of a button?
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  19/04/2011 |
|
Status: Verified
GOAL:
How to access the SCREEN-VALUE of a SmartDataViewer Field on the CHOOSE of a BUTTON located on the SmartWindow containing the SmartDataViewer?
FACT(s) (Environment):
Windows
Progress 9.x
OpenEdge 10.x
FIX:
The following is a step by step procedure to create a SmartWindow containing a SmartDataObject, SmartDataViewer, SmartToolBar and a Button. The sixth step containing the BUTTON CHOOSE trigger code to access the SCREEN-VALUE of a SmartDataViewer field:
1. Create a SmartDataObject against the Customer Table of the Sports2000 database.
2. Create a SmartDataViewer against the above SmartDataObject.
3. Create a new SmartWindow.
4. Drop the SmartDataObject and the SmartDataViewer on the SmartWindow accepting the default links.
5. Drop a SmartToolBar on the SmartWindow and accept the default links.
6. Write the following code behind the CHOOSE event of the button:
DO:
DEFINE VARIABLE hViewer AS HANDLE NO-UNDO.
DEFINE VARIABLE cAllFieldsHandles AS CHARACTER NO-UNDO.
DEFINE VARIABLE hMyFieldHandle AS HANDLE NO-UNDO.
DEFINE VARIABLE cMyFieldName AS CHARACTER NO-UNDO.
DEFINE VARIABLE cDisplayedFields AS CHARACTER NO-UNDO.
DEFINE VARIABLE iCounter AS INTEGER NO-UNDO.
ASSIGN
cMyFieldName = "Country"
hViewer = h_vcust2000
cDisplayedFields = DYNAMIC-FUNCTION('getDisplayedFields' IN hViewer)
iCounter = LOOKUP(cMyFieldName,cDisplayedFields)
cAllFieldsHandles = DYNAMIC-FUNCTION('getFieldHandles' IN hViewer)
hMyFieldHandle = WIDGET-HANDLE(ENTRY(iCounter,cAllFieldsHandles)).
MESSAGE hMyFieldHandle:SCREEN-VALUE
VIEW-AS ALERT-BOX INFO BUTTONS OK.
END.
7. Save the application.
8. Run the application.
9. Navigate to the record desired using the SmartToolBar.
10. Click on the button to have the screen-value of the country field displayed in a message box.