<?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 How to Expand the LayerList in API 4.3 in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-expand-the-layerlist-in-api-4-3/m-p/580447#M54153</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Below is how I am able to expand the LayerList automatically in the ArcGIS API for JavaScript 4.3.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;On an event click, I wanted the LayerList to automatically expand to show the sublayers within my MapImageLayer. &amp;nbsp;In 3.x,&amp;nbsp;two classes were replaced: &amp;nbsp;one to expand the layerlist and another to change the icon. &amp;nbsp;I am unsure how to change the attributes in the&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When using Inspect Element, I can see that the following attributes&amp;nbsp;change in the html:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt;1. the &lt;STRONG&gt;title&lt;/STRONG&gt; changes from "Expand" to "Collapse" and &lt;STRONG&gt;aria-expanded&lt;/STRONG&gt; changes from" false" to" true"&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;div class="esri-layer-list__item-container"&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;span tabindex="0" &lt;STRONG&gt;title="Expand"&lt;/STRONG&gt; class="esri-layer-list__child-toggle" role="button" &lt;STRONG&gt;aria-expanded="false"&lt;/STRONG&gt; aria-controls="layerListDiv_15afbb8a47b-object-23"&amp;gt;...&amp;lt;/span&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt;2. &amp;nbsp;the &lt;STRONG&gt;hidden=" "&lt;/STRONG&gt;&amp;nbsp;is an element when the above elements are = Expand and false, respectively, and the &lt;STRONG&gt;hidden=" " &lt;/STRONG&gt;is removed from when the above elements are = Collapse and true, respectively&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;ul class="esri-layer-list__list esri-layer-list__--independent" id="layerListDiv_15afbb8a47b-object-23" role="group" &lt;STRONG&gt;hidden=" "&lt;/STRONG&gt;&amp;gt;...&amp;lt;/ul&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt;3. &amp;nbsp;the&lt;STRONG&gt; icon&lt;/STRONG&gt; changes from&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;span class="esri-layer-list__child-toggle-icon--closed esri-icon-rigjht-triangle-arrow" aria-hidden="true"&amp;gt;&amp;lt;/span&amp;gt;&lt;/P&gt;&lt;P&gt;to&lt;/P&gt;&lt;P&gt;&amp;lt;span class="&lt;SPAN&gt;esri-layer-list__child-toggle-icon--opened esri-icon-down-arrow" aria-hidden="true"&amp;gt;&amp;lt;/span&amp;gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt;&lt;STRONG&gt;Here is my code snippet:&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;//*********************************************&lt;BR /&gt; // Function Expand Layer List&lt;BR /&gt; //*********************************************&lt;BR /&gt; function expandLayerList() {&lt;BR /&gt; // change aria-expanded&lt;BR /&gt; var x = document.getElementsByClassName("esri-layer-list__child-toggle")[0].getAttribute("aria-expanded");&lt;BR /&gt; if (x == "false") {&lt;BR /&gt; x = "true"&lt;BR /&gt; document.getElementsByClassName("esri-layer-list__child-toggle")[0].setAttribute("aria-expanded", x);&lt;BR /&gt; }&lt;BR /&gt; // change title&lt;BR /&gt; var y = document.getElementsByClassName("esri-layer-list__child-toggle")[0].getAttribute("title");&lt;BR /&gt; if (y == "Expand") {&lt;BR /&gt; y = "Collapse";&lt;BR /&gt; document.getElementsByClassName("esri-layer-list__child-toggle")[0].setAttribute("title", y);&lt;BR /&gt; }&lt;BR /&gt; // change hidden&lt;BR /&gt; var z = document.getElementsByClassName("esri-layer-list__list esri-layer-list__list--independent")[1].hasAttribute("hidden");&lt;BR /&gt; alert(z);&lt;BR /&gt; if (z) {&lt;BR /&gt; var h1 = document.getElementsByClassName("esri-layer-list__list esri-layer-list__list--independent")[1];&lt;BR /&gt; h1.removeAttribute("hidden");&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;} // end expandLayerList function&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 23 Mar 2017 16:34:13 GMT</pubDate>
    <dc:creator>LoriEmerson_McCormack</dc:creator>
    <dc:date>2017-03-23T16:34:13Z</dc:date>
    <item>
      <title>How to Expand the LayerList in API 4.3</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-expand-the-layerlist-in-api-4-3/m-p/580447#M54153</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Below is how I am able to expand the LayerList automatically in the ArcGIS API for JavaScript 4.3.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;On an event click, I wanted the LayerList to automatically expand to show the sublayers within my MapImageLayer. &amp;nbsp;In 3.x,&amp;nbsp;two classes were replaced: &amp;nbsp;one to expand the layerlist and another to change the icon. &amp;nbsp;I am unsure how to change the attributes in the&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When using Inspect Element, I can see that the following attributes&amp;nbsp;change in the html:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt;1. the &lt;STRONG&gt;title&lt;/STRONG&gt; changes from "Expand" to "Collapse" and &lt;STRONG&gt;aria-expanded&lt;/STRONG&gt; changes from" false" to" true"&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;div class="esri-layer-list__item-container"&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;span tabindex="0" &lt;STRONG&gt;title="Expand"&lt;/STRONG&gt; class="esri-layer-list__child-toggle" role="button" &lt;STRONG&gt;aria-expanded="false"&lt;/STRONG&gt; aria-controls="layerListDiv_15afbb8a47b-object-23"&amp;gt;...&amp;lt;/span&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt;2. &amp;nbsp;the &lt;STRONG&gt;hidden=" "&lt;/STRONG&gt;&amp;nbsp;is an element when the above elements are = Expand and false, respectively, and the &lt;STRONG&gt;hidden=" " &lt;/STRONG&gt;is removed from when the above elements are = Collapse and true, respectively&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;ul class="esri-layer-list__list esri-layer-list__--independent" id="layerListDiv_15afbb8a47b-object-23" role="group" &lt;STRONG&gt;hidden=" "&lt;/STRONG&gt;&amp;gt;...&amp;lt;/ul&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt;3. &amp;nbsp;the&lt;STRONG&gt; icon&lt;/STRONG&gt; changes from&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;span class="esri-layer-list__child-toggle-icon--closed esri-icon-rigjht-triangle-arrow" aria-hidden="true"&amp;gt;&amp;lt;/span&amp;gt;&lt;/P&gt;&lt;P&gt;to&lt;/P&gt;&lt;P&gt;&amp;lt;span class="&lt;SPAN&gt;esri-layer-list__child-toggle-icon--opened esri-icon-down-arrow" aria-hidden="true"&amp;gt;&amp;lt;/span&amp;gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt;&lt;STRONG&gt;Here is my code snippet:&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;//*********************************************&lt;BR /&gt; // Function Expand Layer List&lt;BR /&gt; //*********************************************&lt;BR /&gt; function expandLayerList() {&lt;BR /&gt; // change aria-expanded&lt;BR /&gt; var x = document.getElementsByClassName("esri-layer-list__child-toggle")[0].getAttribute("aria-expanded");&lt;BR /&gt; if (x == "false") {&lt;BR /&gt; x = "true"&lt;BR /&gt; document.getElementsByClassName("esri-layer-list__child-toggle")[0].setAttribute("aria-expanded", x);&lt;BR /&gt; }&lt;BR /&gt; // change title&lt;BR /&gt; var y = document.getElementsByClassName("esri-layer-list__child-toggle")[0].getAttribute("title");&lt;BR /&gt; if (y == "Expand") {&lt;BR /&gt; y = "Collapse";&lt;BR /&gt; document.getElementsByClassName("esri-layer-list__child-toggle")[0].setAttribute("title", y);&lt;BR /&gt; }&lt;BR /&gt; // change hidden&lt;BR /&gt; var z = document.getElementsByClassName("esri-layer-list__list esri-layer-list__list--independent")[1].hasAttribute("hidden");&lt;BR /&gt; alert(z);&lt;BR /&gt; if (z) {&lt;BR /&gt; var h1 = document.getElementsByClassName("esri-layer-list__list esri-layer-list__list--independent")[1];&lt;BR /&gt; h1.removeAttribute("hidden");&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;} // end expandLayerList function&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Mar 2017 16:34:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-expand-the-layerlist-in-api-4-3/m-p/580447#M54153</guid>
      <dc:creator>LoriEmerson_McCormack</dc:creator>
      <dc:date>2017-03-23T16:34:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to Expand the LayerList in API 4.3</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-expand-the-layerlist-in-api-4-3/m-p/580448#M54154</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Lori, thanks for passing this on, it was helpful! &amp;nbsp;I've found a simpler way to do this, which involves setting one object in the&amp;nbsp;"esri-layer-list__child-toggle" elements. &amp;nbsp;It's called "data-item", which has a property called "open". &amp;nbsp;Set this to true. &amp;nbsp;The LayerList widget responds to this in the background.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is my sample code:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;nbsp; &lt;SPAN style="color: #000080; font-weight: bold;"&gt;function &lt;/SPAN&gt;&lt;SPAN&gt;layerList_ExpandAll&lt;/SPAN&gt;(expand) {
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: #000080; font-weight: bold;"&gt;var &lt;/SPAN&gt;&lt;SPAN style="color: #458383;"&gt;ctSpans &lt;/SPAN&gt;= &lt;SPAN style="color: #660e7a; font-weight: bold;"&gt;document&lt;/SPAN&gt;.&lt;SPAN style="color: #7a7a43;"&gt;getElementsByClassName&lt;/SPAN&gt;(&lt;SPAN style="color: #008000; font-weight: bold;"&gt;"esri-layer-list__child-toggle"&lt;/SPAN&gt;);
&lt;SPAN style="color: #808080;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #000080; font-weight: bold;"&gt;for &lt;/SPAN&gt;(&lt;SPAN style="color: #000080; font-weight: bold;"&gt;var &lt;/SPAN&gt;&lt;SPAN style="color: #458383;"&gt;i &lt;/SPAN&gt;= &lt;SPAN style="color: #0000ff;"&gt;0&lt;/SPAN&gt;; &lt;SPAN style="color: #458383;"&gt;i &lt;/SPAN&gt;&amp;lt; &lt;SPAN style="color: #458383;"&gt;ctSpans&lt;/SPAN&gt;.&lt;SPAN style="color: #660e7a; font-weight: bold;"&gt;length&lt;/SPAN&gt;; &lt;SPAN style="color: #458383;"&gt;i&lt;/SPAN&gt;++)
&lt;SPAN style="color: #808080;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #458383;"&gt;ctSpans&lt;/SPAN&gt;[&lt;SPAN style="color: #458383;"&gt;i&lt;/SPAN&gt;][&lt;SPAN style="color: #008000; font-weight: bold;"&gt;"data-item"&lt;/SPAN&gt;].&lt;SPAN style="color: #660e7a; font-weight: bold;"&gt;open &lt;/SPAN&gt;= expand;
&lt;SPAN style="color: #808080;"&gt;&amp;nbsp; &lt;/SPAN&gt;}&lt;/PRE&gt;&lt;P&gt;Calling&amp;nbsp;layerList_ExpandAll(true) expands all layers and&amp;nbsp;&lt;SPAN&gt;layerList_ExpandAll(&lt;/SPAN&gt;&lt;SPAN&gt;false&lt;/SPAN&gt;&lt;SPAN&gt;) collapses all layers.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 00:57:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-expand-the-layerlist-in-api-4-3/m-p/580448#M54154</guid>
      <dc:creator>JimNoel</dc:creator>
      <dc:date>2021-12-12T00:57:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to Expand the LayerList in API 4.3</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-expand-the-layerlist-in-api-4-3/m-p/580449#M54155</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks, Jim. &amp;nbsp;Your solution is elegant.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 26 Jun 2017 22:17:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-expand-the-layerlist-in-api-4-3/m-p/580449#M54155</guid>
      <dc:creator>LoriEmerson_McCormack</dc:creator>
      <dc:date>2017-06-26T22:17:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to Expand the LayerList in API 4.3</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-expand-the-layerlist-in-api-4-3/m-p/580450#M54156</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Jim - this is great, thank you! Would you mind providing a full example of how you implement your layerList_Expandall function in a map? I'm still quite new to JavaScript. I've been able to get this portion to work in my code, but it doesn't always consistently run (ex: it will sometimes only open the first portion of my legend, but leave the rest of the sublayers closed or not open anything all, both when calling it via window.onload). I know I'm doing something wrong, but I can't seem to place what it is.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you in advance - your sample code has definitely helped me out a lot!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 Sep 2017 14:49:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-expand-the-layerlist-in-api-4-3/m-p/580450#M54156</guid>
      <dc:creator>HollieK</dc:creator>
      <dc:date>2017-09-13T14:49:46Z</dc:date>
    </item>
  </channel>
</rss>

