Is it possible to achieve multiple selection in cascading dropdowns

Certified Senior Developer

I have a requirement where I'm having 5 dropdowns, based on the values (Multiple Selection) in first dropdown, the remaining dropdown values need get auto filtered out (Cascading Dropdowns). Is it possible to achieve? The one way of implementing is after multiple selections in first dropdown we need to keep a button and on click of button we can pass to next dropdowns. But without having button is it possible to achieve.

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Senior Developer

    Hi  ,

    Here is an example of multiple selection using cascading dropdowns.

    a!localVariables(
      local!countries: { "India", "USA" },
      local!statesByCountry: {
        "India": { "Rajasthan", "Maharashtra" },
        "USA": { "California", "Texas" }
      },
      local!citiesByState: {
        "Rajasthan": { "Jaipur", "Udaipur" },
        "Maharashtra": { "Mumbai", "Pune" },
        "California": { "Los Angeles", "San Francisco" },
        "Texas": { "Houston", "Dallas" }
      },
      local!areasByCity: {
        "Jaipur": {
          "Malviya Nagar",
          "Vaishali Nagar",
          "Mansarovar"
        },
        "Udaipur": {
          "Hiran Magri",
          "Fatehpura",
          "Shobhagpura"
        },
        "Mumbai": { "Andheri", "Bandra", "Dadar" },
        "Pune": { "Wakad", "Hinjewadi", "Kothrud" },
        "Los Angeles": { "Hollywood", "Venice", "Beverly Hills" },
        "San Francisco": { "Mission District", "SoMa", "Sunset" },
        "Houston": { "Downtown", "Midtown", "Uptown" },
        "Dallas": { "Deep Ellum", "Bishop Arts", "Lakewood" }
      },
      local!selectedCountry,
      local!selectedState,
      local!selectedCities,
      local!selectedArea,
      local!showSelectedChoiceforState: touniformstring(
        a!forEach(
          items: local!selectedCountry,
          expression: index(local!statesByCountry, fv!item, {})
        )
      ),
      local!showSelectedChoiceforCity: touniformstring(
        a!forEach(
          items: local!selectedState,
          expression: index(local!citiesByState, fv!item, {})
        )
      ),
      local!showSelectedChoiceforArea: touniformstring(
        a!forEach(
          items: local!selectedCities,
          expression: index(local!areasByCity, fv!item, {})
        )
      ),
      {
        a!multipleDropdownField(
          label: "Country",
          choiceLabels: local!countries,
          choiceValues: local!countries,
          value: local!selectedCountry,
          saveInto: {
            local!selectedCountry,
            a!save(
              {
                local!selectedArea,
                local!selectedCities,
                local!selectedState
              },
              null
            )
          }
        ),
        a!multipleDropdownField(
          label: "State",
          choiceLabels: local!showSelectedChoiceforState,
          choiceValues: local!showSelectedChoiceforState,
          value: local!selectedState,
          saveInto: {
            local!selectedState,
            a!save(
              {
                local!selectedArea,
                local!selectedCities
              },
              null
            )
          }
        ),
        a!multipleDropdownField(
          label: "City",
          choiceLabels: local!showSelectedChoiceforCity,
          choiceValues: local!showSelectedChoiceforCity,
          value: local!selectedCities,
          saveInto: {
            local!selectedCities,
            a!save(local!selectedArea, null)
          }
        ),
        a!multipleDropdownField(
          label: "Area",
          choiceLabels: local!showSelectedChoiceforArea,
          choiceValues: local!showSelectedChoiceforArea,
          value: local!selectedArea,
          saveInto: { local!selectedArea }
        )
      }
    )

Reply
  • 0
    Certified Senior Developer

    Hi  ,

    Here is an example of multiple selection using cascading dropdowns.

    a!localVariables(
      local!countries: { "India", "USA" },
      local!statesByCountry: {
        "India": { "Rajasthan", "Maharashtra" },
        "USA": { "California", "Texas" }
      },
      local!citiesByState: {
        "Rajasthan": { "Jaipur", "Udaipur" },
        "Maharashtra": { "Mumbai", "Pune" },
        "California": { "Los Angeles", "San Francisco" },
        "Texas": { "Houston", "Dallas" }
      },
      local!areasByCity: {
        "Jaipur": {
          "Malviya Nagar",
          "Vaishali Nagar",
          "Mansarovar"
        },
        "Udaipur": {
          "Hiran Magri",
          "Fatehpura",
          "Shobhagpura"
        },
        "Mumbai": { "Andheri", "Bandra", "Dadar" },
        "Pune": { "Wakad", "Hinjewadi", "Kothrud" },
        "Los Angeles": { "Hollywood", "Venice", "Beverly Hills" },
        "San Francisco": { "Mission District", "SoMa", "Sunset" },
        "Houston": { "Downtown", "Midtown", "Uptown" },
        "Dallas": { "Deep Ellum", "Bishop Arts", "Lakewood" }
      },
      local!selectedCountry,
      local!selectedState,
      local!selectedCities,
      local!selectedArea,
      local!showSelectedChoiceforState: touniformstring(
        a!forEach(
          items: local!selectedCountry,
          expression: index(local!statesByCountry, fv!item, {})
        )
      ),
      local!showSelectedChoiceforCity: touniformstring(
        a!forEach(
          items: local!selectedState,
          expression: index(local!citiesByState, fv!item, {})
        )
      ),
      local!showSelectedChoiceforArea: touniformstring(
        a!forEach(
          items: local!selectedCities,
          expression: index(local!areasByCity, fv!item, {})
        )
      ),
      {
        a!multipleDropdownField(
          label: "Country",
          choiceLabels: local!countries,
          choiceValues: local!countries,
          value: local!selectedCountry,
          saveInto: {
            local!selectedCountry,
            a!save(
              {
                local!selectedArea,
                local!selectedCities,
                local!selectedState
              },
              null
            )
          }
        ),
        a!multipleDropdownField(
          label: "State",
          choiceLabels: local!showSelectedChoiceforState,
          choiceValues: local!showSelectedChoiceforState,
          value: local!selectedState,
          saveInto: {
            local!selectedState,
            a!save(
              {
                local!selectedArea,
                local!selectedCities
              },
              null
            )
          }
        ),
        a!multipleDropdownField(
          label: "City",
          choiceLabels: local!showSelectedChoiceforCity,
          choiceValues: local!showSelectedChoiceforCity,
          value: local!selectedCities,
          saveInto: {
            local!selectedCities,
            a!save(local!selectedArea, null)
          }
        ),
        a!multipleDropdownField(
          label: "Area",
          choiceLabels: local!showSelectedChoiceforArea,
          choiceValues: local!showSelectedChoiceforArea,
          value: local!selectedArea,
          saveInto: { local!selectedArea }
        )
      }
    )

Children
No Data