Select to view content in your preferred language

Return all Fields in PopupTemplate

6480
13
09-27-2011 01:30 PM
JoeJeurissen
New Contributor
Is there a way to return all the attributes for a PopupTemplate without declaring all of them in the fieldInfos object?  For a InfoTemplate all you have to do is this to return every attribute.

var template=new esri.InfoTemplate("My Title","${*}");


I've tried a bunch of different ways and the closest I came up with is:

var template=new esri.dijit.PopupTemplate({
  title: result.layerName,
  fieldInfos: [{ fieldName: "*",visible: true}]
 });


The problem with that is there is only 1 returned key/value pair.  The key is the asterisk and the single value is all of the results grouped together.
0 Kudos
13 Replies
RobertScheitlin__GISP
MVP Emeritus

Fui,

  Sorry for the confusion. The PopupTemplate in 4.x does not have a description property it has a content property

So it would be:

var template = new PopupTemplate({  
          title:"Marriage in NY, Zip Code: {ZIP}", 
          content: "{*}"  
          });
Fui_FangThong
New Contributor

I tried with the sandbox and it works without the loop. Thank you so much Robert! 

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no">
  <title>Intro to PopupTemplate - 4.8</title>

  <style>
    html,
    body,
    #viewDiv {
      padding: 0;
      margin: 0;
      height: 100%;
      width: 100%;
    }
  </style>

  <link rel="stylesheet" href="https://js.arcgis.com/4.8/esri/css/main.css">
  <script src="https://js.arcgis.com/4.8/"></script>

  <script>
    require([
      "esri/Map",
      "esri/PopupTemplate",
      "esri/layers/FeatureLayer",
      "esri/views/MapView",
      "dojo/domReady!"
    ], function(
      Map,
      PopupTemplate,
      FeatureLayer,
      MapView
    ) {

      // Create the map
      var map = new Map({
        basemap: "gray"
      });

      // Create the MapView
      var view = new MapView({
        container: "viewDiv",
        map: map,
        center: [-73.950, 40.702],
        zoom: 11
      });

      var template = { // autocasts as new PopupTemplate()
        title: "Marriage in NY, Zip Code: {ZIP}",
        content: "{*}"  
      };

      // Reference the popupTemplate instance in the
      // popupTemplate property of FeatureLayer
      var featureLayer = new FeatureLayer({
        url: "https://services.arcgis.com/V6ZHFr6zdgNZuVG0/ArcGIS/rest/services/NYCDemographics1/FeatureServer/0",
        outFields: ["*"],
        popupTemplate: template
      });
      map.add(featureLayer);
    });
  </script>
</head>

<body>
  <div id="viewDiv"></div>
</body>

</html>
JulienREME
New Contributor

Sorry to ask you this late after you last answer, any idea why this doesnt work on 4.16 ?

Thanks,

KevinMacLeod3
New Contributor III

Julien REME‌ this is not implemented in the 4.x API. It was taken out at 4.12. I can confirm it is not present in 4.17  either which is coming in the fall. Hopefully it will return for 4.18 or 4.19. For now, you have to implement this yourself such as with code in these comments.

https://community.esri.com/thread/246593-js-414-mapimagelayer-sublayers-default-popup-template#comme... 

https://community.esri.com/thread/239435-412-popup-changes-why-and-what-now#comment-943951 

0 Kudos