I’ve created a custom control for SharePoint 2010. This control let you connect two lookup fields so that the second lookup field contains only a subset of all values depending on the selected value of the first lookup field.
The control can handle both rendering methods of SharePoint for lookup fields: If there are more then 20 items in a lookup dropdown it will be rendered alternatively as input text box and not as input dropdown…
But… It’s alpha!!!
This is the demo list where you start using the demo.
Add a new item. You see two input controls. Both are empty.
Now you open the dropdown list of the first field:
There are values in – Leave it on “(none)” for now.
Open the dropdown of the second field:
Now select the value “List1-Value1” in the first dropdown.
Now open the second dropdown. Now there are values in there :
The second dropdown was filled with values depending on the selected value of the first dropdown.
Lets have a look behind the scene.
Open the List “This list defines the value dependencies between the main list and the conditional list”:
This list defines the values for the second dropdown depending on the values of the first dropdown.
For value “List1-Value1” you’ll find there 4 values:
Lets have a look into the project:
The Test project has 4 SharePoint List definitions… “List 1” is the “main list” and “List 3” is the “conditional list”. “List 2” will contain the items you create. “RefList” contains the dependencies between “List 1” and “List 3”.
“List 2” contains to custom list forms:
“New2” is used to create new items, “Edit2” is used to edit items.
Lets have a look into “New2”. There are only a few customizations for using the Conditional Lookup control.
This references to the input fields “ff1” and “ff2”: