Kbase 19010: ADM2 - How to Initialize a Combo-Box or Selection-List
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  03/11/2008 |
|
Status: Verified
GOAL:
How to Initialize the LIST-ITEMS of a combo-box or selection-list.
GOAL:
ADM2
FACT(s) (Environment):
Progress 9.x
FIX:
The following sample code makes the following assumptions:
- You are going to initialize the drop down portion of a combo-box that is on a SmartDataViewer (SDV).
- The SDO that is going to be used to initialize the combo-box is not the same SDO that is used as the data source for the SDV.
- The SDO that is going to be used to initialize the combo-box is to be linked to the SDV via a link named "List".
- You will load the SalesRep initials from the SalesRep table from the sports2000 database into the combo-box.
- The function in the SDO that is responsible for actually loading the data is called setListItems.
Put the following code in the initializeObject procedure in the SDV:
DEFINE VARIABLE hProc AS HANDLE NO-UNDO.
DEFINE VARIABLE cProc AS CHARACTER NO-UNDO.
IF getUIBMode() = "" THEN
DO WITH FRAME {&FRAME-NAME}:
ASSIGN cProc = DYNAMIC-FUNCTION("linkHandles","LIST-SOURCE")
hProc = WIDGET-HANDLE(cProc).
DYNAMIC-FUNCTION("setListItems" IN hProc,
RowObject.SalesRep:HANDLE).
END.
RUN SUPER.
Create a function called setListItems in the SDO that takes an input parameter called hWidget with a data type of handle and that returns a logical value. Put the following code inside that function:
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 getQueryPosition() NE "LastRecord" OR
getQueryPosition() NE "OnlyRecord" THEN
RUN fetchNext.
ELSE
LEAVE.
END.
RETURN TRUE.
END.
RETURN FALSE.