Kbase 19067: ADM2 - How to Initialize a Combo-Box or Selection-List (#2)
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  10/16/2008 |
|
Status: Verified
GOAL:
Another way way to initialize the LIST-ITEMS of a combo-box or selection-list.
FACT(s) (Environment):
Progress 9.x
FIX:
The following is a step by step description of how to populate a COMBO-BOX or a SELECTION-LIST using the PUBLISH and SUBSCRIBE statements:
1) Start the AppBuilder and connect to the Sports2000 database.
2) Create a SmartDataObject (SDO) against the customer table to include the
CustNum, Name, Country and SalesRep fields and save it as dCustomer.w.
3) Create a SmartDataObject (SDO) against the SalesRep table to include the
SalesRep field and save it as dSalesRep.w.
4) Create a SmartDataViewer (SDV) against the Customer SDO to include the
CustNum, Name, and Country fields and save it as vCustomer.w.
5) Drop the SalesRep SmartDataObject dSalesRep.w onto the Customer
SmartDataViewer.
6) Drop a combo-box from the object palette onto the SmartDataViewer. Use the
combo-box property sheet to name it SalesRep and label it Sales Rep. Use
the database field icon of the property sheet to map it to the SalesRep
field.
7) Place the following code before the "RUN SUPER" statement in the
initializeObject procedure of the Customer SmartDataViewer:
DO WITH FRAME {&FRAME-NAME}:
PUBLISH "LoadSalesRepList" (INPUT RowObject.SalesRep:HANDLE).
END.
8) Create the procedure LoadSalesRepList in the SalesRep SDO with the
following code:
DEFINE INPUT PARAMETER hWidget AS HANDLE NO-UNDO.
IF VALID-HANDLE(hWidget) THEN
IF INDEX("COMBO-BOX,SELECTION-LIST",hWidget:TYPE) 0 THEN
DO:
ASSIGN hWidget:LIST-ITEMS = "".
RUN fetchFirst.
REPEAT:
hWidget:ADD-LAST(RowObject.SalesRep).
IF INDEX("LastRecord,OnlyRecord", DYNAMIC-FUNCTION('getQueryPosition':U)) = 0 THEN
RUN fetchNext.
ELSE
LEAVE.
END.
END.
9) Place the following code before the "RUN SUPER" statement in the
initializeObject procedure of the SalesRep SmartDataObject:
SUBSCRIBE TO "LoadSalesRepList" ANYWHERE.
10) Create a new application to include SmartWindowObject containing the
Customer SmartDataObject, the Customer SmartDataViewer, a smart toolbar
and the following SmartLinks:
Link Type Source Object Target Object
---------- ------------- -------------
DATA h_dCustomer h_vCustomer
NAVIGATION h_dyntoolbar h_dCustomer
TABLEIO h_dyntoolbar h_vCustomer
UPDATE h_vCustomer h_dCustomer
11) Save and run this application.