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

Step 2. Add Logic to the Reusable Part

This step will define the component as a TreeDesign component and create an OnAdd method which is invoked when the form executes an ADD_ENTRY command on the Tree List control.
1.  Switch to the Source tab. Extend the Begin_Com Role() keyword to include the highlighted code:
Begin_Com Role(*EXTENDS #PRIM_PANL *IMPLEMENTS #prim_tree.iTreedesign *LISTFIELDS #Listfields) Displayposition(1) Height(270) Left(0) Tabposition(1) Top(0) Width(500)
*implements #Prim_Tree.iTreeDesign means this component implements a User Defined Control which will be implemented as the row of a tree control.
*listfields #ListFields refers to a Group_By which defines fields to be mapped into this component when a row is added to the Tree List. i.e. when an instance of this component is created.
2.  Define the ListFields Group_By:
Group_By Name(#Listfields) Fields(#xEmployeeIdentification #xEmployeeSurname #xEmployeeGivenNames #xEmployeeStreet #xEmployeeCity #xEmployeeState #xEmployeePostalCode #xEmployeeStartDate #xEmployeeTerminationDate #xDepartmentDescription #xDepartmentCode #xEmployeeImageThumbnail)
3.  Define an OnAdd method to redefine the method in Prim_Tree.iTreeDesign. Add logic to perform the following:
Set the MoreLess cursor to the Windows Hand cursor
Set the panel initial Height based on MoreLess Top property plus MoreLess Height property
Set EmployeeName Caption to the form "GivenName, Surname (EmployeeIdentification)"
Set Street Caption to xEmployeeStreet
Set City Caption to xEmployeeCity
Set State Caption to xEmployeeState
Set PostCode Caption to xEmployeePostalCode
Set Department Caption to the form "Dept Description (Dept Code)"
If xEmployeeTerminationDate is not SQLNULL
Set StartDate ThemeDrawStyle property POOR
Set StartDate Caption to 'No longer employed - ' + xEmployeeTerminationDate
Else
Set StartDate ThemDrawStyle property to GOOD
Set StartDate Caption to 'Employed - ' + xEmployeeStartDate
End If
Set EmployeeImage FileName property to xEmployeeImageThumbnail
     Note: The Label component has a default property of Caption. This statement sets the label's Caption:
#Label1 := #std_text
     Your code should look like the following:
Mthroutine Name(OnAdd) Options(*REDEFINE)