Two questions about input select

I’m trying to wrap my head around inputs and more specifically selects. The basics work but now I got stuck with these two things.

  1. Can I “chain” multiple selects to drill down into data? In the example below I’d like to set d.categories_select.value to the value that was selected in the first select.

categories = ["country", "age_group"] viewof categories_select = Inputs.select(categories, {label: "Categories"}) viewof sub_category = Inputs.select(data.map(d => **d.categories_select.value**)})

  1. It’s recommended to add a null value to the select list if you want to be able to select all values (see code below). That works but I’m how I can add a label null value and make it appear as the first item in the list.

viewof countries = Inputs.select(data.map(d => d.about_you_country).concat([null]), {sort: true, unique: true, label: "Country", value: null})

  1. Yup, you can refer to the value of an Inputs.select anywhere else in your notebook, including to filter an array that you pass as the options for another Inputs.select.

  2. You can use any value to mean “all” if you write the filter logic to look for it. And you can concatenate a value onto the front (start, beginning) of an array with [newValue, ...existingArray].

I tried doing both in the notebook below. If your data’s in a different format or you have a more specific question, feel free to post an example notebook so I can see it in context!

1 Like

Thanks for the help @tophtucker!

  1. My dataset looks a bit different. The categories are actually column names. See this example

  2. Got it. I was trying to mimic this example where you have a key/value pair. So having “all countries” equal “null” but couldn’t get that to work.