Example: Detail Trigger for Tree Widget
The following example uses a component variable $PARENTSTRUCTURE$
to contain the tree ValRep list for parent tree items, and the global
variable $$LIST
to contain the field ValRep list for lower-level tree items.
trigger detail variables string NEWVAL string ITEMVALREP string ACTION string NODE string FIRSTCOLUMN endvariables getitem ACTION,$result,2 getitem NEWVAL,$result,3 ; get the parent structure of selected item. ; if the selected item is not in the ValRep, ; use the field ValRep call LP_GETSTRUCTURE(NEWVAL,$PARENTSTRUCTURE$,NODE,FIRSTCOLUMN) selectcase ACTION case "EXPAND" ; if a node was expanded in the tree ; get the last item of the item ValRep ; and add an extra column for the nodes ; that contain additional items, ; else use the code in the valueChanged trigger getitem $3, $PARENTSTRUCTURE$, -1 if($3 = "?") ; get the correct data activate "TRESERV".BLDORG(NEWVAL,ITEMVALREP) ; update $fieldvalrep $fieldvalrep(TREFLD.DUMMY) = "0=;%%ITEMVALREP" endif case "" ; If an item was double-clicked in the tree ; check whether the correct node is selected if(NODE = "EMPLOYEE") ; where EMPLOYEE is the name of the tree item ; type for the node message/nobeep "Clicked on %%FIRSTCOLUMN" $5 = "%%TREFLD.DUMMY;%%$PARENTSTRUCTURE$" $$list = "" activate "TREMOD".EXEC($5) ; activate an edit form for data in the tree, ; where $5 contains the selected ValRep data if($$LIST != "") $fieldvalrep(TREFLD.DUMMY) = "0=;%%$$LIST" endif endif ; other actions: case "OPEN" ; open another list ... endselectcase end; detail