AnsweredAssumed Answered

API 4.9 - How do I populate a <select> element in a Widget?

Question asked by LTS_DSolari on Oct 25, 2018
Latest reply on Oct 26, 2018 by LTS_DSolari

I'm writing a simple widget that pulls unique values from a feature service's field and zooms to all features with the selected value. I figured the best way to do this was populate a HTML select element with the field values as options. Unfortunately, I've hit a roadblock and both of the detours I can think of don't seem to work.

  • If if map my choices to a function that returns option elements inside the render function (as shown here) only the first element is rendered
  • If I construct the select element myself I can't find a way to bind this to the renderer's version of the DOM (or however JSX rendering works) or set the inner HTML.

I've attached my app so you folks can get a better idea of what I'm trying to do. Do npm install then npm start to compile the app and get it running on localhost. The widget has a choices property with the fetched string values and a comboBox property with the constructed HTMLElements. Please let me know what you think, I'm not sure if i'm doing something wrong or if I've hit a bug and I'd like to know if 4.9 has it's own version of a select/combobox element I can use instead.