<?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: Select all calcite-pick-list-item(s) without a calciteListChange event in Calcite Design System Questions</title>
    <link>https://community.esri.com/t5/calcite-design-system-questions/select-all-calcite-pick-list-item-s-without-a/m-p/1207923#M211</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/193359"&gt;@GregoryBologna&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It would probably be easier to add a conditional in the event listener's callback function (handleTaxParcelTypesChange), rather than dynamically adding/removing the listener. Here is an example:&lt;/P&gt;&lt;P&gt;&lt;A href="https://codepen.io/benesri/pen/bGvXZgz?editors=0011" target="_blank"&gt;https://codepen.io/benesri/pen/bGvXZgz?editors=0011&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 30 Aug 2022 21:55:55 GMT</pubDate>
    <dc:creator>BenElan</dc:creator>
    <dc:date>2022-08-30T21:55:55Z</dc:date>
    <item>
      <title>Select all calcite-pick-list-item(s) without a calciteListChange event</title>
      <link>https://community.esri.com/t5/calcite-design-system-questions/select-all-calcite-pick-list-item-s-without-a/m-p/1207762#M210</link>
      <description>&lt;P&gt;I have a&amp;nbsp;&lt;SPAN&gt;calcite-pick-list with a&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;calciteListChange event listener. This is working fine except when I reset the&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;calcite-pick-list-item(s)&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;to have them all selected. I do not want the change event to fire. I tried adding a&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;removeEventListener before selecting the items and then returning the calciteListChange event listener but this didn't help.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Creating the&amp;nbsp;&lt;SPAN&gt;calcite-pick-list&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;let taxparcelTypes = document.createElement('calcite-pick-list');
taxparcelTypes.setAttribute('id', 'pao-taxparceltypes-pick-list');
taxparcelTypes.setAttribute('multiple', '');
taxparcelTypes.setAttribute('heading-level', '1');
taxparcelTypes.addEventListener(
   'calciteListChange',
   handleTaxParcelTypesChange
);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Reset &lt;SPAN&gt;calcite-pick-list and s&lt;/SPAN&gt;elect all items&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;let el = document.getElementById('pao-taxparceltypes-pick-list');
if (el) {
// remove to prevent changed event which causes query to execute
 el.removeEventListener('calciteListChange', handleTaxParcelTypesChange);
 Object.keys(el.children).forEach((key) =&amp;gt; {
 if (el.children[key].nodeName.toLowerCase() === 'calcite-pick-list-item') {
   el.children[key].selected = true;
 }
});
// add back changed event
//el.addEventListener('calciteListChange', handleTaxParcelTypesChange);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;My calcite-pick-list with two items unselected that will be selected in code fragment above.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="GregoryBologna_0-1661874382200.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/49833iFF66DC5D084027BD/image-size/medium?v=v2&amp;amp;px=400" role="button" title="GregoryBologna_0-1661874382200.png" alt="GregoryBologna_0-1661874382200.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;The attached Event Listeners&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="GregoryBologna_1-1661874512272.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/49834i023764805B1C6110/image-size/medium?v=v2&amp;amp;px=400" role="button" title="GregoryBologna_1-1661874512272.png" alt="GregoryBologna_1-1661874512272.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Aug 2022 16:00:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/calcite-design-system-questions/select-all-calcite-pick-list-item-s-without-a/m-p/1207762#M210</guid>
      <dc:creator>GregoryBologna</dc:creator>
      <dc:date>2022-08-30T16:00:11Z</dc:date>
    </item>
    <item>
      <title>Re: Select all calcite-pick-list-item(s) without a calciteListChange event</title>
      <link>https://community.esri.com/t5/calcite-design-system-questions/select-all-calcite-pick-list-item-s-without-a/m-p/1207923#M211</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/193359"&gt;@GregoryBologna&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It would probably be easier to add a conditional in the event listener's callback function (handleTaxParcelTypesChange), rather than dynamically adding/removing the listener. Here is an example:&lt;/P&gt;&lt;P&gt;&lt;A href="https://codepen.io/benesri/pen/bGvXZgz?editors=0011" target="_blank"&gt;https://codepen.io/benesri/pen/bGvXZgz?editors=0011&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Aug 2022 21:55:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/calcite-design-system-questions/select-all-calcite-pick-list-item-s-without-a/m-p/1207923#M211</guid>
      <dc:creator>BenElan</dc:creator>
      <dc:date>2022-08-30T21:55:55Z</dc:date>
    </item>
    <item>
      <title>Re: Select all calcite-pick-list-item(s) without a calciteListChange event</title>
      <link>https://community.esri.com/t5/calcite-design-system-questions/select-all-calcite-pick-list-item-s-without-a/m-p/1208864#M213</link>
      <description>&lt;P&gt;Thanks for the example. Works perfect.&lt;/P&gt;</description>
      <pubDate>Thu, 01 Sep 2022 19:42:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/calcite-design-system-questions/select-all-calcite-pick-list-item-s-without-a/m-p/1208864#M213</guid>
      <dc:creator>GregoryBologna</dc:creator>
      <dc:date>2022-09-01T19:42:15Z</dc:date>
    </item>
  </channel>
</rss>

