<?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 Use of Features widget with featurelayer added to map. in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/use-of-features-widget-with-featurelayer-added-to/m-p/1307765#M81672</link>
    <description>&lt;P&gt;I posted the question of how to use the features widget with a feature layer (fL) added to the map (&lt;A href="https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/features-widget-using-featurelayer-added-to-map/m-p/1306408#M81630" target="_self"&gt;link&lt;/A&gt;&amp;nbsp;) and&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/400217"&gt;@LaurenBoyd&lt;/a&gt;&amp;nbsp; responded that you have to define the fL's popupTemplate before you can fetch the features. That was the correct response. However, in my case I have hundreds of layers that can be added to the map as the discretion of the user, therefore I'd like to use a default popup display for all layers.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Prior version 4.12, you could simply use&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;  popupTemplate: {
        title: "Title",
        content: "*"
    }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;to define the popuptemplate. Since then, ESRI stated that: "&lt;SPAN&gt;As of version 4.12, content can no longer be set using a wildcard, e.g.&amp;nbsp;&lt;/SPAN&gt;*&lt;SPAN&gt;. Instead, set the&amp;nbsp;&lt;/SPAN&gt;Popup's&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#defaultPopupTemplateEnabled" target="_blank" rel="noopener"&gt;defaultPopupTemplateEnabled&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp;property to&amp;nbsp;&lt;/SPAN&gt;true&lt;SPAN&gt;."&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;To use the defaultPopupTemplateEnabled you must first set the&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;view.popup.popupEnabled = true&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, to use the features widget, you must set the above property to false.&lt;/P&gt;&lt;P&gt;So, to display all attributes of a fL in a popup I wrote this script (see below) to get all the fields of the feature layer and set the popuptemplate with those fields. It works but the format of the display is not satisfactory. See this &lt;A href="https://codepen.io/lkoumis1/pen/BaGJeaK" target="_self"&gt;codepen link&lt;/A&gt;&amp;nbsp;and click on a feature to see the popup display. I'd love to get the table style format to display the results. Any ideas?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;reactiveUtils.on(
          () =&amp;gt; view,
          "click",
          (event) =&amp;gt; {
            featuresWidget.open({
              location: event.mapPoint,
              fetchFeatures: true
            });
            view.map.layers.map(function (lyr) {
              if (lyr.type === "feature"){
               let content =""
                console.log(lyr.fields)
                console.log(lyr)
                lyr.fields.forEach((field) =&amp;gt; {
                  let alias = field.alias
                  let name = field.name
                  content += "&amp;lt;p&amp;gt;" + alias + ":{" + name + "}&amp;lt;/p&amp;gt;&amp;lt;br&amp;gt;"
                })
             
                console.log(content)
                var popupTemplate = { // autocasts as new PopupTemplate()
                    title: lyr.title,
                    content: content
                };               
                lyr.popupTemplate = popupTemplate;
              }

            })
          }
        );&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 12 Jul 2023 21:01:55 GMT</pubDate>
    <dc:creator>LefterisKoumis</dc:creator>
    <dc:date>2023-07-12T21:01:55Z</dc:date>
    <item>
      <title>Use of Features widget with featurelayer added to map.</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/use-of-features-widget-with-featurelayer-added-to/m-p/1307765#M81672</link>
      <description>&lt;P&gt;I posted the question of how to use the features widget with a feature layer (fL) added to the map (&lt;A href="https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/features-widget-using-featurelayer-added-to-map/m-p/1306408#M81630" target="_self"&gt;link&lt;/A&gt;&amp;nbsp;) and&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/400217"&gt;@LaurenBoyd&lt;/a&gt;&amp;nbsp; responded that you have to define the fL's popupTemplate before you can fetch the features. That was the correct response. However, in my case I have hundreds of layers that can be added to the map as the discretion of the user, therefore I'd like to use a default popup display for all layers.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Prior version 4.12, you could simply use&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;  popupTemplate: {
        title: "Title",
        content: "*"
    }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;to define the popuptemplate. Since then, ESRI stated that: "&lt;SPAN&gt;As of version 4.12, content can no longer be set using a wildcard, e.g.&amp;nbsp;&lt;/SPAN&gt;*&lt;SPAN&gt;. Instead, set the&amp;nbsp;&lt;/SPAN&gt;Popup's&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#defaultPopupTemplateEnabled" target="_blank" rel="noopener"&gt;defaultPopupTemplateEnabled&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp;property to&amp;nbsp;&lt;/SPAN&gt;true&lt;SPAN&gt;."&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;To use the defaultPopupTemplateEnabled you must first set the&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;view.popup.popupEnabled = true&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, to use the features widget, you must set the above property to false.&lt;/P&gt;&lt;P&gt;So, to display all attributes of a fL in a popup I wrote this script (see below) to get all the fields of the feature layer and set the popuptemplate with those fields. It works but the format of the display is not satisfactory. See this &lt;A href="https://codepen.io/lkoumis1/pen/BaGJeaK" target="_self"&gt;codepen link&lt;/A&gt;&amp;nbsp;and click on a feature to see the popup display. I'd love to get the table style format to display the results. Any ideas?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;reactiveUtils.on(
          () =&amp;gt; view,
          "click",
          (event) =&amp;gt; {
            featuresWidget.open({
              location: event.mapPoint,
              fetchFeatures: true
            });
            view.map.layers.map(function (lyr) {
              if (lyr.type === "feature"){
               let content =""
                console.log(lyr.fields)
                console.log(lyr)
                lyr.fields.forEach((field) =&amp;gt; {
                  let alias = field.alias
                  let name = field.name
                  content += "&amp;lt;p&amp;gt;" + alias + ":{" + name + "}&amp;lt;/p&amp;gt;&amp;lt;br&amp;gt;"
                })
             
                console.log(content)
                var popupTemplate = { // autocasts as new PopupTemplate()
                    title: lyr.title,
                    content: content
                };               
                lyr.popupTemplate = popupTemplate;
              }

            })
          }
        );&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jul 2023 21:01:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/use-of-features-widget-with-featurelayer-added-to/m-p/1307765#M81672</guid>
      <dc:creator>LefterisKoumis</dc:creator>
      <dc:date>2023-07-12T21:01:55Z</dc:date>
    </item>
    <item>
      <title>Re: Use of Features widget with featurelayer added to map.</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/use-of-features-widget-with-featurelayer-added-to/m-p/1307995#M81683</link>
      <description>&lt;P&gt;Hi there,&amp;nbsp;&lt;/P&gt;&lt;P&gt;Instead of having to set the fields content yourself for the layer's popupTemplate, you can simply set the &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html#content" target="_self"&gt;popupTemplate.content&lt;/A&gt; to fields content element. In the SDK doc, you will see examples of this.&lt;/P&gt;&lt;P&gt;In any case, I updated your codepen to set the fields content for the first layer:&amp;nbsp;&lt;A href="https://codepen.io/U_B_U/pen/gOQvmyY?editors=1000" target="_blank"&gt;https://codepen.io/U_B_U/pen/gOQvmyY?editors=1000&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Hope this helps,&lt;/P&gt;&lt;P&gt;-Undral&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jul 2023 17:22:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/use-of-features-widget-with-featurelayer-added-to/m-p/1307995#M81683</guid>
      <dc:creator>UndralBatsukh</dc:creator>
      <dc:date>2023-07-13T17:22:32Z</dc:date>
    </item>
  </channel>
</rss>

