To fill in a tree view so that also items which do not include any items are included, use nested SELECT statements. This example shows all departments and sections in the PSLMST file:
To see how the example works, copy this code and paste it to a form component:
BEGIN_COM role(*EXTENDS #PRIM_FORM) HEIGHT(331) LEFT(334) TOP(157) WIDTH(315)
DEFINE_COM class(#PRIM_TRVW) name(#TRVW_1) DISPLAYPOSITION(1) HEIGHT(257) LEFT(18) PARENT(#COM_OWNER) TABPOSITION(1) TOP(24) WIDTH(271)
DEFINE_COM class(#PRIM_TVCL) name(#TVCL_1) KEYPOSITION(1) LEVEL(1) PARENT(#TRVW_1) SOURCE(#DEPTMENT) VISIBLE(False)
DEFINE_COM class(#PRIM_TVCL) name(#TVCL_3) KEYPOSITION(1) LEVEL(2) PARENT(#TRVW_1) SOURCE(#SECTION) VISIBLE(False)
DEFINE_COM class(#PRIM_TVCL) name(#TVCL_2) DISPLAYPOSITION(1) IMAGE(#VI_DEPTCL) IMAGEEXPANDED(#VI_DEPTOP) LEVEL(1) PARENT(#TRVW_1) SOURCE(#DEPTDESC)
DEFINE_COM class(#PRIM_TVCL) name(#TVCL_4) DISPLAYPOSITION(1) IMAGE(#VI_SECTCL) IMAGEEXPANDED(#VI_SECTOP) LEVEL(2) PARENT(#TRVW_1) SOURCE(#SECDESC)
EVTROUTINE handling(#TRVW_1.Initialize) options(*NOCLEARMESSAGES *NOCLEARERRORS)
SELECT fields(#DEPTMENT #DEPTDESC) from_file(DEPTAB)
ADD_ENTRY to_list(#TRVW_1)
SELECT fields(#SECTION #SECDESC) from_file(SECTAB) with_key(#DEPTMENT)
ADD_ENTRY to_list(#TRVW_1)
ENDSELECT
ENDSELECT
ENDROUTINE
END_COM