[ |../../index.htm#lansa/frmeng01_0540.htm]
You are here:

Step 2. Add Load Data Logic

The Tree View will have three levels, departments, employees and employee notes. All data will be loaded initially.
1.  Create an AddEntry method routine. This needs five input parameters:

     Your code should look like the following:
Mthroutine Name(AddEntry)
Define_Map For(*INPUT) Class(#STD_OBJ) Name(#Column1)
Define_Map For(*INPUT) Class(#STD_desc) Name(#Column2) Mandatory(' ')
Define_Map For(*INPUT) Class(#STD_descl) Name(#Column3) Mandatory(' ')
Define_Map For(*INPUT) Class(#prim_bmp) Name(#Image) Mandatory(*NULL) Pass(*BY_REFERENCE)
Define_Map For(*input) Class(#Prim_tvit) Name(#ParentItem) Mandatory(*Null) Pass(*By_reference)
Endroutine
       Note: All except the first map have a Mandatory() parameter, meaning the parameter will be given its Mandatory value if not passed. These parameters are optional.
2.  To complete the AddEntry routine, the following logic is required:
Assign STD_OBJ to Column1
Assign STD_DESC to Column2
Assign STD_DESCL to Column3
Add entry to TreeView
Set reference to TreeView.CurrentItem.ParentItem from ParentItem
Set refrence to TreeViewcurrentItem.Image to Image
Set TreeView.CurrentItem.hasChildren property to Yes for level 1 and 2
Set TreeView.CurrentItem.hasChildren poperty to No for level 3
     Your code should look like the following:
Mthroutine Name(AddEntry)
Define_Map For(*INPUT) Class(#STD_OBJ) Name(#Column1)
Define_Map For(*INPUT) Class(#STD_desc) Name(#Column2) Mandatory(' ')
Define_Map For(*INPUT) Class(#STD_descl) Name(#Column3) Mandatory(' ')
Define_Map For(*INPUT) Class(#prim_bmp) Name(#Image) Mandatory(*NULL) Pass(*BY_REFERENCE)
Define_Map For(*input) Class(#Prim_tvit) Name(#ParentItem) Mandatory(*Null) Pass(*By_reference)
#std_obj := #Column1
#std_desc := #Column2
#std_descl := #Column3
Add_Entry To_List(#TreeView)
#TreeView.Currentitem.ParentItem <= #ParentItem
#TreeView.Currentitem.image <= #Image