<?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: Change the order of features in popups in 4.x JS API in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/change-the-order-of-features-in-popups-in-4-x-js/m-p/1354033#M82944</link>
    <description>I set the index on the property mapView.popup.viewModel.selectedFeatureIndex&lt;BR /&gt;&lt;BR /&gt;// Show first the node, if there is a node inside list of selected graphics.&lt;BR /&gt;mapView.watch("popup.viewModel.features", (graphics: Graphic[]) =&amp;gt; {&lt;BR /&gt;if (graphics &amp;amp;&amp;amp; graphics.length &amp;gt; 1) {&lt;BR /&gt;for (let i = 0; i &amp;lt; graphics.length; i++) {&lt;BR /&gt;const graphic = graphics[i];&lt;BR /&gt;if (graphic.layer.title === config.layerNames.nodeLayerName) {&lt;BR /&gt;mapView.popup.viewModel.selectedFeatureIndex = i;&lt;BR /&gt;break;&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;});&lt;BR /&gt;&lt;BR /&gt;</description>
    <pubDate>Tue, 28 Nov 2023 14:06:28 GMT</pubDate>
    <dc:creator>MichelRietveld</dc:creator>
    <dc:date>2023-11-28T14:06:28Z</dc:date>
    <item>
      <title>Change the order of features in popups in 4.x JS API</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/change-the-order-of-features-in-popups-in-4-x-js/m-p/1005269#M70929</link>
      <description>&lt;P&gt;The layers in my map often have many overlapping features and when the popup is opened I'd like to be able to order them by a field in order to have the most relevant features at the top of the stack.&amp;nbsp; Was able to find an older 3.x example of this, but I can't find the equivalent for 4.x.&amp;nbsp; Any suggestions?&amp;nbsp; No need to rewrite this for me, just point me to the right object/method/event if it exists, thanks!&lt;/P&gt;&lt;PRE&gt;connect.connect(map.infoWindow, &lt;SPAN class="hljs-string"&gt;"onSetFeatures"&lt;/SPAN&gt;, &lt;SPAN class="hljs-function"&gt;&lt;SPAN class="hljs-keyword"&gt;function&lt;/SPAN&gt; () &lt;/SPAN&gt;{  
            &lt;SPAN class="hljs-keyword"&gt;var&lt;/SPAN&gt; orderedFeatures = [];  
            &lt;SPAN class="hljs-function"&gt;&lt;SPAN class="hljs-title"&gt;for&lt;/SPAN&gt;(&lt;SPAN class="hljs-params"&gt;&lt;SPAN class="hljs-keyword"&gt;var&lt;/SPAN&gt; i = &lt;SPAN class="hljs-number"&gt;0&lt;/SPAN&gt;; i&amp;lt; map.infoWindow.features.length; i++&lt;/SPAN&gt;)&lt;/SPAN&gt; {  
                &lt;SPAN class="hljs-keyword"&gt;if&lt;/SPAN&gt; (map.infoWindow.features[i]._layer.id === &lt;SPAN class="hljs-string"&gt;'ImportantLayer'&lt;/SPAN&gt;) {  
                    orderedFeatures.unshift(map.infoWindow.features[i]);  
                }  
                &lt;SPAN class="hljs-keyword"&gt;else&lt;/SPAN&gt; {  
                    orderedFeatures.push(map.infoWindow.features[i]);  
                }  
            }  
            map.infoWindow.features = orderedFeatures;  
        });  &lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 27 Nov 2020 22:59:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/change-the-order-of-features-in-popups-in-4-x-js/m-p/1005269#M70929</guid>
      <dc:creator>JoeRogan</dc:creator>
      <dc:date>2020-11-27T22:59:19Z</dc:date>
    </item>
    <item>
      <title>Re: Change the order of features in popups in 4.x JS API</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/change-the-order-of-features-in-popups-in-4-x-js/m-p/1277669#M80840</link>
      <description>&lt;P&gt;Any luck on this ? I am facing the same issue and want resolution for this ?&lt;/P&gt;</description>
      <pubDate>Wed, 12 Apr 2023 07:48:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/change-the-order-of-features-in-popups-in-4-x-js/m-p/1277669#M80840</guid>
      <dc:creator>DheerajGambhir1</dc:creator>
      <dc:date>2023-04-12T07:48:22Z</dc:date>
    </item>
    <item>
      <title>Re: Change the order of features in popups in 4.x JS API</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/change-the-order-of-features-in-popups-in-4-x-js/m-p/1334085#M82366</link>
      <description>&lt;DIV&gt;&lt;SPAN&gt;mapView&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;watch&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;"popup.viewModel.features"&lt;/SPAN&gt;&lt;SPAN&gt;, (&lt;/SPAN&gt;&lt;SPAN&gt;graphics&lt;/SPAN&gt;&lt;SPAN&gt;) &lt;/SPAN&gt;&lt;SPAN&gt;=&amp;gt;&lt;/SPAN&gt;&lt;SPAN&gt; {&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;console&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;log&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;"features"&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;graphics&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;mapView&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;popup&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;viewModel&lt;/SPAN&gt;&lt;SPAN&gt;);&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; });&lt;/SPAN&gt;&lt;/DIV&gt;</description>
      <pubDate>Mon, 02 Oct 2023 11:21:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/change-the-order-of-features-in-popups-in-4-x-js/m-p/1334085#M82366</guid>
      <dc:creator>MichelRietveld</dc:creator>
      <dc:date>2023-10-02T11:21:44Z</dc:date>
    </item>
    <item>
      <title>Re: Change the order of features in popups in 4.x JS API</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/change-the-order-of-features-in-popups-in-4-x-js/m-p/1353559#M82921</link>
      <description>&lt;P&gt;Hi Michel -&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm also trying to reorder features in the popup. I tried using a watch on the&amp;nbsp;&lt;SPAN&gt;popup.viewModel.features object, but then when I try to reorder the features it triggers the watch again, causing an infinite loop. I also tried comparing the current and intended order of features prior to setting the value to avoid triggering the watch again, but the features value seems inconsistent. Any ideas? Thanks&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Nov 2023 16:19:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/change-the-order-of-features-in-popups-in-4-x-js/m-p/1353559#M82921</guid>
      <dc:creator>AnthonyThompsonFWP</dc:creator>
      <dc:date>2023-11-27T16:19:06Z</dc:date>
    </item>
    <item>
      <title>Re: Change the order of features in popups in 4.x JS API</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/change-the-order-of-features-in-popups-in-4-x-js/m-p/1354033#M82944</link>
      <description>I set the index on the property mapView.popup.viewModel.selectedFeatureIndex&lt;BR /&gt;&lt;BR /&gt;// Show first the node, if there is a node inside list of selected graphics.&lt;BR /&gt;mapView.watch("popup.viewModel.features", (graphics: Graphic[]) =&amp;gt; {&lt;BR /&gt;if (graphics &amp;amp;&amp;amp; graphics.length &amp;gt; 1) {&lt;BR /&gt;for (let i = 0; i &amp;lt; graphics.length; i++) {&lt;BR /&gt;const graphic = graphics[i];&lt;BR /&gt;if (graphic.layer.title === config.layerNames.nodeLayerName) {&lt;BR /&gt;mapView.popup.viewModel.selectedFeatureIndex = i;&lt;BR /&gt;break;&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;});&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 28 Nov 2023 14:06:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/change-the-order-of-features-in-popups-in-4-x-js/m-p/1354033#M82944</guid>
      <dc:creator>MichelRietveld</dc:creator>
      <dc:date>2023-11-28T14:06:28Z</dc:date>
    </item>
    <item>
      <title>Re: Change the order of features in popups in 4.x JS API</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/change-the-order-of-features-in-popups-in-4-x-js/m-p/1354440#M82959</link>
      <description>&lt;P&gt;Thanks - that does at least work to set the initially selected index, which works for now.&lt;/P&gt;</description>
      <pubDate>Tue, 28 Nov 2023 23:29:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/change-the-order-of-features-in-popups-in-4-x-js/m-p/1354440#M82959</guid>
      <dc:creator>AnthonyThompsonFWP</dc:creator>
      <dc:date>2023-11-28T23:29:32Z</dc:date>
    </item>
    <item>
      <title>Re: Change the order of features in popups in 4.x JS API</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/change-the-order-of-features-in-popups-in-4-x-js/m-p/1648775#M87597</link>
      <description>&lt;P&gt;Building on&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/68795"&gt;@MichelRietveld&lt;/a&gt;'s answer, you can in-place sort the graphics array the callback receives to sort the features how you want.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;mapView.watch("popup.viewModel.features", (graphics: Graphic[]) =&amp;gt; {
  graphics.sort((a, b) =&amp;gt; {
    // Magical sort logic here
  });
});&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Sep 2025 22:52:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/change-the-order-of-features-in-popups-in-4-x-js/m-p/1648775#M87597</guid>
      <dc:creator>bytesnz</dc:creator>
      <dc:date>2025-09-08T22:52:24Z</dc:date>
    </item>
  </channel>
</rss>

