There are three different types of dependencies properties that can be added to a dropdown. Below are the three types are:
- ap_KeyDependencyProperties - This should be the set of properties that uniquely identifies a record.
- ap_FilterDependecyProperties - These are properties that filter the list of the return records. Can also be fields in the ap_KeyDependencyProperties.
- ap_NonKeyDependencyProperties - These are additional properties that are obtained from the selected record.
Note: A Dependency Property can belong to more than 1 of these collections, but properties in the ap_NonKeyDependencyProperties should not be in any of the other collections.
Each dependency property can also implement an on changed event. The two main change event handlers are am_OnIdChanged and am_OnFilterIdChanged. The ap_NonKeyDependencyProperties should not implement either of these change handlers.
When am_OnIdChanged gets invoked it will do the following:
- If field is in the ap_FilterDependencyProperties it will call am_OnFilterIdChanged
- Creates a new entity and populates all of the ap_KeyDependencyProperties that are not non null ap_FilterDependencyProperties
- If any of the ap_KeyDependencyProperties are not null then it attempts to fetch the record with a query object with only the ap_KeyDependencyProperties set.
When am_OnFilterIdChanged gets invoked it will do the following
- Clear all records in the dropdown
- Clear all of the ap_NonKeyDependencyProperties and any ap_KeyDependencyProperty that is not in the ap_FilterDependencyProperties
- Set the currently selected dropdown item to null
- Fire the change events
All ap_KeyDependencyProperties should use the am_OnIdChanged as the change hanlder even if they are also in the ap_FilterDependencyProperties. Properties that are only in the ap_FilterDependencyProperties should use am_OnFilterIdChanged. Properties that are in the ap_NonKeyDependencyProperties should not have any changed event hanlder unless it is some custom logic.
Properties that are in the ap_KeyDependencyProperties should also be in the ap_FilterDependencyProperty when they are keys to the record but not the field that gets entered into the dropdown.