Cascading Choices (Parent-Child)
Cascading Choices or Filtered Data fields
You can easily add cascading behaviour using the Form Designer.
Our platform is smart enough to handle many levels of cascading choices too – i.e. where one field filters another, which in turn filters another etc.
NOTE: You must be using a Data Source for your child field(s) in order to add cascading functionality to your Form. We recommend using Data Sources on all your Choices fields – it is a simpler approach and means that common lists of options such as “Yes/No” can be shared and reused across fields and Forms. |
Lets assume we want the following cascading behaviour:
Country
field
-> County
field
So when the user chooses a Country, then the County field should only show Counties for that selected Country.
Now lets assume the Country and City Data Sources are as follows:
Country Code | Country Name |
UK | United Kingdom |
etc.. | etc.. |
US | United States |
City | County | Country Code |
Cambridge | Cambridgeshire | UK |
Oxford | Oxfordshire | UK |
Lincoln | Lincolnshire | UK |
Sacramento | California | US |
Las Vegas | Nevada | US |
etc… | etc.. | etc… |
The steps to implement cascading behaviour using the above example data and setup is as follows:
1. In the Form designer, add a Choices field and name it Country.
2. Select the Country field – this will show the properties for the field on the right hand side.
3. Find the property titled “Answer Choices” and select “Data Source”.
This will show a bunch of options for Data Sources.
4. In the drop down list of available Data Sources, find the Countries Data Source and select it.
Sweet! At this stage your Country field will now show a list of countries as defined in the Countries data source.
Now lets hook up the County field, along with it’s cascading filter!
5. Add another Choices field and name it County .
6. Repeat steps 2 – 4 on your County field, this time round you want to select the County’s data source.
7. While still on the County field’s properties, you should see a “add criterion” link just below the data sources drop down.
Click this link to add a new filter.
8. You’ll now see three fields displayed that let you define how the filter should work.
What we want to do is have the rows in the County’s data source be filtered according to the Country Code selected in the Country field.
- The first filter drop down shows the columns available on the County’s data source.
Choose the “Country Code” option. - The second filter drop down shows the logical operations we can use for filtering.
Choose the “equals” option. - The third field is a text field where you can enter the name of another field or just a static value.
We want to filter by the Country field’s answer, so enter {{Country}} into the text box.
Your handiwork should look like the screenshot below:
Now if you save the Form and set it to be in Test mode, you can try it out on your device.
You should see that once you choose a Country, the County field is automatically filtered to only show the County’s rows that have Country Code = the selected country.