Step 4. Implement Dynamic Picklists in By Location filter
VFW090 – Field Visualizations
1. Open the
filter reusable part (iiiVFW05) in the editor.a. In the
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
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 S , a monitor is defined with a source of Deptment and a target of Section.
- When iiiDepartment changes, the method in the iiiSection visualization is run. A reference to the source object is received allowing the method to be called to obtain the value.
- Immediately after the has finished, the method will be run.
2. In the filter, iiiVFW05, after the
, 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
method in the component (iiiVFW22).3. Extend the
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
filter iiiVFW05.6. Execute the Framework and select the
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.