Cascader how can i access value

I'm working on a cascading dropdown in Retool, and I'm trying to access the nested values within the structure. Here is an example of the data I'm using:

[
  {
    "value": "a",
    "label": "A"
  },
  {
    "value": "b",
    "label": "B"
  },
  {
    "value": "c",
    "label": "C"
  },
  {
    "value": "d",
    "label": "D"
  },
  {
    "value": "e",
    "label": "E"
  },
  {
    "value": "f",
    "label": "F",
    "children": [
      {
        "value": "h",
        "label": "H"
      }
    ]
  },
  {
    "value": "i",
    "label": "I",
    "children": [
      {
        "value": "k",
        "label": "K"
      },
      {
        "value": "m",
        "label": "M"
      }
    ]
  }
]

normal value I can access that way

{{ xyz.value == "a" }}

I'm trying to figure out how I can access nested values like "h", "k", and "m". I want the dropdown to show both parent and child values. Any guidance on how to do this in Retool would be greatly appreciated!

Thanks!

Hi @ohi_Ahmed, I edited your post to make the array more legible.

Here is how the structure looks like in the State:

If we wanted to access h, it would be {{ cascader1.structure[5].children[0].value }}

Could you expand a bit more on your use case? I would like to know where is that we're trying to reference these values.

1 Like