<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: populate combobox from a local json array file in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/populate-combobox-from-a-local-json-array-file/m-p/1161276#M76922</link>
    <description>&lt;P&gt;There's a couple of ways you can do this.&lt;/P&gt;&lt;P&gt;One is to iterate over the array and add a new calcite-combobox-item to the combobox.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;const countyselection =  document.getElementById('beg_county');
for (let item of countyList) {
  const comboItem = document.createElement('calcite-combobox-item');
  comboItem.setAttribute('value', item);
  comboItem.setAttribute('text-label', item);
  countyselection.appendChild(comboItem);
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is fine, but could be improved because it's updating the DOM on each iteration. You could use a Fragment to limit it to a single DOM update.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;const countyselection =  document.getElementById('beg_county');
const fragment = document.createDocumentFragment();
for (let item of countyList) {
  const comboItem = document.createElement('calcite-combobox-item');
  comboItem.setAttribute('value', item);
  comboItem.setAttribute('text-label', item);
  fragment.appendChild(comboItem);
}
countyselection.appendChild(fragment);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Another option is to use template literals, and innerHTML, but I think document methods are a little more straightforward.&lt;/P&gt;&lt;P&gt;I haven't tested this, but the comps should already be registered and display correctly.&lt;/P&gt;&lt;P&gt;And for reference, I was just looking at the doc for how the HTML is structured&lt;/P&gt;&lt;P&gt;&lt;A href="https://developers.arcgis.com/calcite-design-system/components/combobox/" target="_blank"&gt;https://developers.arcgis.com/calcite-design-system/components/combobox/&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 05 Apr 2022 17:44:47 GMT</pubDate>
    <dc:creator>ReneRubalcava</dc:creator>
    <dc:date>2022-04-05T17:44:47Z</dc:date>
    <item>
      <title>populate combobox from a local json array file</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/populate-combobox-from-a-local-json-array-file/m-p/1161259#M76921</link>
      <description>&lt;P&gt;I posted this question on the Design Systems forum as well.&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/t5/calcite-design-system-questions/populate-combobox-from-a-local-json-array-file/m-p/1161016#M78" target="_blank" rel="noopener"&gt;https://community.esri.com/t5/calcite-design-system-questions/populate-combobox-from-a-local-json-array-file/m-p/1161016#M78&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Basically, the question is if we can populate a calcite select/combobox/dropdown&amp;nbsp; from an extenal json file?&lt;/P&gt;&lt;P&gt;The code that I used is listed in the script i posted on the design systems (above link)&lt;/P&gt;&lt;P&gt;This is for ArcGIS JS API 4.x and I use ES modules.&lt;/P&gt;</description>
      <pubDate>Tue, 05 Apr 2022 17:18:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/populate-combobox-from-a-local-json-array-file/m-p/1161259#M76921</guid>
      <dc:creator>LefterisKoumis</dc:creator>
      <dc:date>2022-04-05T17:18:43Z</dc:date>
    </item>
    <item>
      <title>Re: populate combobox from a local json array file</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/populate-combobox-from-a-local-json-array-file/m-p/1161276#M76922</link>
      <description>&lt;P&gt;There's a couple of ways you can do this.&lt;/P&gt;&lt;P&gt;One is to iterate over the array and add a new calcite-combobox-item to the combobox.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;const countyselection =  document.getElementById('beg_county');
for (let item of countyList) {
  const comboItem = document.createElement('calcite-combobox-item');
  comboItem.setAttribute('value', item);
  comboItem.setAttribute('text-label', item);
  countyselection.appendChild(comboItem);
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is fine, but could be improved because it's updating the DOM on each iteration. You could use a Fragment to limit it to a single DOM update.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;const countyselection =  document.getElementById('beg_county');
const fragment = document.createDocumentFragment();
for (let item of countyList) {
  const comboItem = document.createElement('calcite-combobox-item');
  comboItem.setAttribute('value', item);
  comboItem.setAttribute('text-label', item);
  fragment.appendChild(comboItem);
}
countyselection.appendChild(fragment);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Another option is to use template literals, and innerHTML, but I think document methods are a little more straightforward.&lt;/P&gt;&lt;P&gt;I haven't tested this, but the comps should already be registered and display correctly.&lt;/P&gt;&lt;P&gt;And for reference, I was just looking at the doc for how the HTML is structured&lt;/P&gt;&lt;P&gt;&lt;A href="https://developers.arcgis.com/calcite-design-system/components/combobox/" target="_blank"&gt;https://developers.arcgis.com/calcite-design-system/components/combobox/&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Apr 2022 17:44:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/populate-combobox-from-a-local-json-array-file/m-p/1161276#M76922</guid>
      <dc:creator>ReneRubalcava</dc:creator>
      <dc:date>2022-04-05T17:44:47Z</dc:date>
    </item>
  </channel>
</rss>

