Step 4 Implement Dynamic Picklists in By Location filter

VLF Windows Application Development

Step 4. Implement Dynamic Picklists in By Location filter

VFW090 – Field Visualizations

1.  Open the Employees by Location filter reusable part (iiiVFW05) in the editor.

a.  In the Design view, delete the fields DEPTMENT and SECTION.

b.  Add fields iiiDepartment and iiiSection

c.  Adjust the main panel width to show the dropdowns.

d.  Switch to the Source tab. Position at the top of the code. Use the Replace dialog to replace DEPTMENT with iiiDepartment in the following lines:

Group_by Name(#XG_KEYS).. .
Def_Cond . . 
Evtroutine Handling(#DEPTMENT.Changed) . .

 

e.  Replace SECTION with iiiSection, in the following line:

Group_by Name(#XG_KEYS) . . 

     Note:

  • In the Section's Dynamic Picklist, a monitor is defined with a source of Deptment and a target of Section.
  • When iiiDepartment changes, the ApplyMonitorValue method in the iiiSection visualization is run. A reference to the source object is received allowing the GetValue method to be called to obtain the value.
  • Immediately after the ApplyMonitorValue has finished, the Load method will be run.

2.  In the filter, iiiVFW05, after the BEGIN_COM, define the monitor component, with a source of iiiDepartment and a target of iiiSection.

Define_Com Class(#prim_lm) Name(#DepartmentSection) Source(#iiiDepartment) Target(#iiiSection)

 

     Changes to department code will be processed by the ApplyMonitoredValue method in the Sections Dynamic Picklist component (iiiVFW22).

3.  Extend the  iiiDepartment.Changed event routine for the field iiiSection.

     Add the following code (highlighted in red).

Evtroutine Handling(#iiiDepartment.Changed) Options(*NOCLEARMESSAGES *NOCLEARERRORS)
Set Com(#Search_Button) Enabled(*SearchOK)
* Ensure the Section is valid after a department change
#iiiSection := *null

Select Fields(#SECTION) From_File(sectab) With_Key(#iiiDepartment)

#iiiSection := #SECTION

Leave

Endselect

Endroutine

 

     Note: The new code ensures the filter changes the value of iiiSection to the first appropriate value, by reading the first record from SECTAB for the selected Department code.

5.  Compile the By Location filter iiiVFW05.

6.  Execute the Framework and select the By Location filter for Employees.

a.  The sections dropdown should be rebuilt whenever the department dropdown selection is changed.

b.  When department selection is changed, the first section for that department should be displayed.