Build dependency between FilterForm fields

#1

In FilterForm component, is there a way to configure a filter field that depends on another filter field? For example, if I choose “CA” in the State filter field, then I like the City filter field to list only cities in CA as options to choose.

1 Like

#2

I don’t think FilterForm supports it out of box.

I would create an action that will update the data source of your City field and trigger it by the “change” event on the State filter field.

1 Like

#3

An example of dependency filter behavior in the FilterForm component:

“behavior” : [{
  “query”: “myFieldSetID.myControlGroupId.State”, // Parent filter item ID (i.e. State)
  “trigger”: “change”,
  “action”: {
    “type”: “UpdateDataSourceFromSelect”,
    “dataSources”: [{
      “id”: “myDataSource.Cities”, // Datasource of the child filter item (i.e. City)
      “path”: “state.id”, // A datasrouce field connected to the parent filter item
      “arrayValue”: false,
      “updateArgument”: “spec”,
      “updateField”: “filter”
      }],
    “followUpActions”: [{
      “action”: {
        “type”: “ClearForm”,
        “target”: “City”, // Child filter item ID
        “selectById”: true
      }
    }]
  }
}]

2 Likes