Step 2. Define a Dynamic Picklist for SKILCODE
VFW090 – Field Visualizations
Fields may have defined. Visualizations may include:
- A reusable part which includes logic to the value of a field as an entry is typed.
- A may be defined with entries retrieved from a file at run time.
For full details refer to the .
In this example you will create a for a new field iiiSkillCode which populates a dropdown from the file SKLTAB.
1. Copy field SKILCODE to create a new field iiiSkillCode, copy rules, visualizations and help text. Open the new field in the editor.
2. A is implemented via a simple reusable part.
Create a new :
iiiVFW20
Skill Code Dynamic Picklist
3. A RP is a non visual component (ancestor PRIM_OBJT) which implements #prim_dc.iDynamicPicklist.
Implementing allows a visualization reusable to the picklist at runtime.
Load - The load method is executed during initialization and any time a monitored value or context changes. This picklist instance is received via the Picklist map. The instance of the picklist is maintained at runtime, meaning that the user must clear the list if new data is required.
See the for more detailed information about .
4. The method routine which will populate the picklist from the file SKLTAB when the field component is loaded onto a form or panel, needs to be completed.
The method routine redefines the method in the component.
Add the following code, after the comment line , replacing the supplied code provided
* Populate the picklist
Select Fields(#skilcode #skildesc) From_File(skltab)
#Picklist.Add( #skilcode #skildesc )
Endselect
Note:
The method displays a . This is part of the redefined method of . The parameter passes a reference to a component PRIM_PKLT, named Picklist in the Load method.
- The method enables your reusable part to add entries to the picklist.
- The clears the picklist.
- The method includes code to clear the picklist.
- Always use to investigate the definition of shipped components such as PRIM_PKLT.
5. Compile your new reusable part.
6. The new field iiiSkillCode which you just created, should be open in the editor.
7. Select the tab and use the toolbar button to insert a :
A dialog is displayed. Select your reusable part iiiVFW20.
8. Select the component and increase its width.
9. Select the and use the tab to change its property to True.
10. Examine the field source code. Note the component definition:
Begin_Com Role(*Dynamic_Picklist #IIIVFW20) Name(#DynamicPicklist) Nomatchaction(Blanks)
End_Com
As with all picklists, dynamic or static, the property needs to be set to determine what to do in the event of the underlying field value not being found in the picklist. For most situations, ShowValue is probably the best choice.
11. Select the item. On the tab, change the property to ShowValue.
12. Save the field definition.
13. Open the (iiiVFW19) in the editor. You will be making similar change as for field iiiGRADE
a. Change the SKILCODE component definition to use the dynamic picklist, .
Define_Com Class(#iiiSkillCode.VisualPicklist) Name(#iiiSkillCode) Displayposition(1) Left(7) Parent(#DETAIL) Tabposition(1) Top(7)
b. Change the item for SKILCODE, to manage iiiSkillCode
Define_Com Class(#PRIM_FWLI) Name(#FWLI_10) Manage(#iiiSkillCode) Parent(#FWLM_2)
c. Close the dialog.
d. At the top of the event routine add the following code:
#SKILCODE := #iiiSkillCode
e. In the method routine, add the following code immediately after the FETCH:
#iiiSkillCode := #SKILCODE
f. Switch to the tab, and increase the width of Skill Code if necessary.
g. Compile your reusable part (iiiVFW19).
14. Execute your Framework and ensure that the correct Skill Code description is shown when an employee skill is selected:
15. Create a new employee skill, using the context menu on the employee skills list view. Notice that the skill code dropdown and grade, initially shows their last value. This is because the fields IIISKILCODE and IIIGRADE are not currently being initialized in the method routine.
16. Add code to to set the new fields to their default value and re-test. Notice that iiiGrade defaults to "Pass" as expected and iiiSkilCode shows blanks, which is its default value, copied from field definition SKILCODE.