Consultor Eletrônico



Kbase 20103: ADM2. Combo-box and SDO Fields
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   11/8/2005
Status: Unverified

GOAL:

How to associate a Progress combo-box with a Progress SmartDataObject (SDO), how to load the different values of a table into a SDO, and save the selected value of the combo-box into the updated SDO.

FACT(s) (Environment):

Progress 9.x

SYMPTOM(s):

ADM2

FIX:

You need the following:


- Connection to Sports2000 database.
- One SmartDataObject (SDO).
- One SmartViewer (SV).
- One SmartWindow (SW).
- One SmartToolbar (STB).

Follow these steps:


1) Create a SDO on the customer table.
2) Choose the fields custnum, name, salesrep, country).
3) Save the SDO with name mySDO.w.
4) Create a SV based on the SDO mySDO.w.
5) Choose the fields custnum, name, country.
6) Insert a new combo-box in the SV.
7) Select the properties sheet of the combo-box and click on the Database Field button.
8) Select the available field of the SDO (SalesRep) and press the OK button.
9) Remove all the values in the property sheet of the combo-box. "Item 1" should be blank.
10) Press the OK button on the Property Sheet of the combo-box.
11) Open the Section Editor for the SV.
12) Write the foloowing code in the DEFINITION SECTION:


DEFINE VARIABLE COMBOINI AS LOGICAL NO-UNDO.

13) In the PROCEDURES SECTION, create a new procedure overriding the "InitializeObject" and write the following before the RUN SUPER statement:


FOR EACH SALESREP:
COMBOINI = ROWOBJECT.SALESREP:ADD-LAST(SALESREP.SALESREP) IN FRAME &FRAME-NAME}.
END.

14) Save the SV with name mySV.w and close it.
15) Create a SW.
16) Place the SDO mySDO.w into the SW.
17) Place the Sv mySV.w into the SW.
18) The Progress Advisor prompts two messages to link the two objects. Press the OK button each time.
19) Place a STB into the SW.
20) The Progress Advisor prompts two messages to link the two objects. Press the OK button each time.
21) Save the SW with name mySW.w.
22) Run the SW.

Notice that the combo-box in the viewer has all the values that the
SalesRep.SalesRep field has, based on the SalesRep table. Each time you change the value of the combo-box, the selected value is stored in the SDO ROWOBJECT.SalesRep field without the need to do anything else.