Step 3 Link Dynamic Picklists

VLF Windows Application Development

Step 3. Link Dynamic Picklists

VFW090 – Field Visualizations

The next example demonstrates how dynamic picklists can be linked. A dynamic picklist for Sections can be loaded from the Section table (SECTAB), but the Sections dynamic  picklist, must be rebuilt whenever the department changes.

1.  Create a new Reusable Part / Dynamic Picklist:

     Name: iiiVFW21

     Description: Departments Dynamic Picklist

2.  Add the following immediately after the comment line * populate dynamic picklist, replacing the supplied code:

* Populate dynamic picklist
Select Fields(#deptment #deptdesc) From_File(deptab)
#Picklist.Add( #deptment #deptdesc )
Endselect

 

     Having completed  Step 2- Define a Dynamic Picklist for SkillCode, you should now be familiar with what this code is doing.

3.  Compile your new reusable part.

4.  Create a new field iiiDepartment by copying field DEPTMENT, copy rules, visualizations and help text. Open the new field in the editor.

5.  Select the Visualizations tab. Use the Tool bar button to add a New Dynamic Picklist. In the Find dialog, select the RP, iiiVFW21.

a.  Select the new VisualPicklist component and adjust the width of the dropdown to display the department description.

b.  Select the VisualPicklist component and use the Details tab to change its DefaultVisual property to True.

c.  Select the DynamicPicklist component and use the Details tab o change its NoMatchAction property to ShowValue.

6.  Save and close the field definition.

7.  Create a new Reusable Part / Dynamic Picklist:

     Name: iiiVFW22

     Description: Section Dynamic Picklist

8.  Add the following code, immediately after the *Populate the picklist comment line, replacing the default code provided:

Select Fields(#section #secdesc) From_File(sectab) With_Key(#deptment)

#Picklist.Add( #section #secdesc )

Endselect

 

9.  There is a new requirement for the Sections Dynamic Picklist. It needs to monitor changes in the field DEPTMENT.

     To do this it needs to also implement Prim_dc.iMonitorSubject and include a method routine for ApplyMonitorValue.

10. Extend your code based on the changes highlighted in red below:

Function Options(*DIRECT)
Begin_Com Role(*EXTENDS #PRIM_OBJT *implements #Prim_dc.iDynamicPicklist #Prim_dc.iMonitorSubject)
Mthroutine Name(Load) Options(*redefine)
#Picklist.RemoveAll

* Populate the picklist
Select Fields(#section #secdesc) From_File(Sectab) With_Key(#Deptment)
#Picklist.Add( #Section #Secdesc )
Endselect
Endroutine
Mthroutine Name(ApplyMonitoredValue) Options(*Redefine)
#Deptment := #MonitorSubject.GetValue

Endroutine

End_Com

 

     Note: The ApplyMonitoredValue routine displays the Define_map defined in its ancestor.

11. Compile the new reusable part.

12. Create a new field iiiSection by copying field SECTION, copy rules, visualizations and help text. Open the new field in the editor.

13. Select the Visualizations tab and add a New Dynamic Picklist and select iiiVFW22.

a.  Adjust the width of the VisualPicklist dropdown.

b.  Make the ViusalPicklist the field's Default visualization.

c.  Select the DynamicPicklist component and use the Details tab to change the NoMatchAction to ShowValue.

14. Save and close the field definition.