Select to view content in your preferred language

Can't get the value for my field in my PopupTemplate

3372
4
Jump to solution
12-03-2015 02:40 PM
TracySchloss
Honored Contributor

Maybe someone can spot what I'm missing.  I have a popupTemplate based on data that is from a linked table.  I am creating a pie chart.  All the values for the chart are in the join table, and from the layer, I just need county name.  Both the layer and the table are in a file geodatabase.

If I create a plain infoTemplate, defined as

var genericInfoTemplate = new InfoTemplate("generic", "${*}");

I can see all the values I want, both from the layer and the joined table.  The county name is available as county.COUNTYNAME

genericInfoTemplate.png

Here is my rest endpoint:

Layer: Veteran Population by Race - current (ID: 2)

Here is how I'm trying to defined my popupTemplate:

  var raceTemplate = new PopupTemplate({
    title: "{county.COUNTYNAME}: Current Veteran Population by Race",
    fieldInfos: [{ 
        fieldName: "VetPop_current_Race.EstAsianVetPop", 
        visible: true, 
        format: { places: 0 }, 
        label:"Asian" 
      },{ 
        fieldName: "VetPop_current_Race.EstBlackVetPop", 
        visible: true, 
        format: { places: 0 }, 
        label:"Black" 
      },{ 
        fieldName: "VetPop_current_Race.EstHispanicVetPop", 
        visible: true, 
        format: { places: 0 }, 
        label:"Hispanic" 
      },{ 
        fieldName: "VetPop_current_Race.EstWhiteVetPop", 
        visible: true, 
        format: { places: 0 }, 
        label:"White" 
      },{ 
        fieldName: "VetPop_current_Race.EstMultiRaceVetPop", 
        visible: true, 
        format: { places: 0 }, 
        label:"Multi-Race" 
      },{ 
        fieldName: "VetPop_current_Race.EstOtherVetPop", 
        visible: true, 
        format: { places: 0 },
        label:"Other"
    }],
    mediaInfos: [{
      type: "piechart",
      caption: "Hover to see value for each race",
        value: { 
          fields: [ 
            "VetPop_current_Race.EstMultiRaceVetPop", 
            "VetPop_current_Race.EstOtherVetPop",
            "VetPop_current_Race.EstWhiteVetPop" ,
            "VetPop_current_Race.EstBlackVetPop", 
            "VetPop_current_Race.EstHispanicVetPop",
            "VetPop_current_Race.EstAsianVetPop"


          ] ,
          theme: "PrimaryColors"
        }
      }]
});

popupTitle.png

Besides not using PopupTemplates very often, this is also the first time I've defined infoTemplates in an ArcGISDynamicMapServiceLayer using myLayername.setInfoTemplates.  I don't know if that makes any difference or not.

0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

Tracy,

  You just needed to include the county.COUNTYNAME field in your fieldInfos array

var raceTemplate = new PopupTemplate({
        title: "{county.COUNTYNAME}: Current Veteran Population by Race",
        fieldInfos: [{
          fieldName: "VetPop_current_Race.EstAsianVetPop",
          visible: true,
          format: {
            places: 0
          },
          label: "Asian"
        }, {
          fieldName: "VetPop_current_Race.EstBlackVetPop",
          visible: true,
          format: {
            places: 0
          },
          label: "Black"
        }, {
          fieldName: "VetPop_current_Race.EstHispanicVetPop",
          visible: true,
          format: {
            places: 0
          },
          label: "Hispanic"
        }, {
          fieldName: "VetPop_current_Race.EstWhiteVetPop",
          visible: true,
          format: {
            places: 0
          },
          label: "White"
        }, {
          fieldName: "VetPop_current_Race.EstMultiRaceVetPop",
          visible: true,
          format: {
            places: 0
          },
          label: "Multi-Race"
        }, {
          fieldName: "VetPop_current_Race.EstOtherVetPop",
          visible: true,
          format: {
            places: 0
          },
          label: "Other"
        }, {
          fieldName: "county.COUNTYNAME",
          visible: false
        }],
        mediaInfos: [{
          type: "piechart",
          caption: "Hover to see value for each race",
          value: {
            fields: [
              "VetPop_current_Race.EstMultiRaceVetPop",
              "VetPop_current_Race.EstOtherVetPop",
              "VetPop_current_Race.EstWhiteVetPop",
              "VetPop_current_Race.EstBlackVetPop",
              "VetPop_current_Race.EstHispanicVetPop",
              "VetPop_current_Race.EstAsianVetPop"
            ],
            theme: "PrimaryColors"
          }
        }]
      });

View solution in original post

4 Replies
RobertScheitlin__GISP
MVP Emeritus

Tracy,

  You just needed to include the county.COUNTYNAME field in your fieldInfos array

var raceTemplate = new PopupTemplate({
        title: "{county.COUNTYNAME}: Current Veteran Population by Race",
        fieldInfos: [{
          fieldName: "VetPop_current_Race.EstAsianVetPop",
          visible: true,
          format: {
            places: 0
          },
          label: "Asian"
        }, {
          fieldName: "VetPop_current_Race.EstBlackVetPop",
          visible: true,
          format: {
            places: 0
          },
          label: "Black"
        }, {
          fieldName: "VetPop_current_Race.EstHispanicVetPop",
          visible: true,
          format: {
            places: 0
          },
          label: "Hispanic"
        }, {
          fieldName: "VetPop_current_Race.EstWhiteVetPop",
          visible: true,
          format: {
            places: 0
          },
          label: "White"
        }, {
          fieldName: "VetPop_current_Race.EstMultiRaceVetPop",
          visible: true,
          format: {
            places: 0
          },
          label: "Multi-Race"
        }, {
          fieldName: "VetPop_current_Race.EstOtherVetPop",
          visible: true,
          format: {
            places: 0
          },
          label: "Other"
        }, {
          fieldName: "county.COUNTYNAME",
          visible: false
        }],
        mediaInfos: [{
          type: "piechart",
          caption: "Hover to see value for each race",
          value: {
            fields: [
              "VetPop_current_Race.EstMultiRaceVetPop",
              "VetPop_current_Race.EstOtherVetPop",
              "VetPop_current_Race.EstWhiteVetPop",
              "VetPop_current_Race.EstBlackVetPop",
              "VetPop_current_Race.EstHispanicVetPop",
              "VetPop_current_Race.EstAsianVetPop"
            ],
            theme: "PrimaryColors"
          }
        }]
      });
TracySchloss
Honored Contributor

Thanks - now I'm trying to include a description under the title.  This is just a string, not pulling from a value.  When I add this, it only loads my title and my chart, but none of the values. 

This seems to match the examples.  I'm adding it right below the title:

var raceTemplate = new PopupTemplate({ 

title: "{county.COUNTYNAME}: Current Veteran Population by Race"

description: "Population values for 2015",

     fieldInfos: [{

....

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Tracy,

  It is either or. You can use description or if you do not use description then the popup will use the fieldinfos that are set to visible and display those in a table layout format. If you want to add some static text as a description then you have to add all your field values text to the description as well.

Here is a example (just using Asian):

var popupDescTemplate = 'Population values for 2015<br><table class="attrTable" cellpadding=0px" cellspacing="0px"><tbody>' +
          '<tr valign="top"><td class="attrName">Asian</td><td class="attrValue">{VetPop_current_Race.EstAsianVetPop}</td></tr>' +
          '</tbody></table>';

      var raceTemplate = new PopupTemplate({
        title: "{county.COUNTYNAME}: Current Veteran Population by Race",
        description: popupDescTemplate,
        fieldInfos: [{
          fieldName: "VetPop_current_Race.EstAsianVetPop",
          visible: true,
          format: {
            places: 0
          },
          label: "Asian"
        }, {
          fieldName: "VetPop_current_Race.EstBlackVetPop",
          visible: true,
          format: {
            places: 0
          },
          label: "Black"
        }, {
          fieldName: "VetPop_current_Race.EstHispanicVetPop",
          visible: true,
          format: {
            places: 0
          },
          label: "Hispanic"
        }, {
          fieldName: "VetPop_current_Race.EstWhiteVetPop",
          visible: true,
          format: {
            places: 0
          },
          label: "White"
        }, {
          fieldName: "VetPop_current_Race.EstMultiRaceVetPop",
          visible: true,
          format: {
            places: 0
          },
          label: "Multi-Race"
        }, {
          fieldName: "VetPop_current_Race.EstOtherVetPop",
          visible: true,
          format: {
            places: 0
          },
          label: "Other"
        }, {
          fieldName: "county.COUNTYNAME",
          visible: false
        }],
        mediaInfos: [{
          type: "piechart",
          caption: "Hover to see value for each race",
          value: {
            fields: [
              "VetPop_current_Race.EstMultiRaceVetPop",
              "VetPop_current_Race.EstOtherVetPop",
              "VetPop_current_Race.EstWhiteVetPop",
              "VetPop_current_Race.EstBlackVetPop",
              "VetPop_current_Race.EstHispanicVetPop",
              "VetPop_current_Race.EstAsianVetPop"
            ],
            theme: "PrimaryColors"
          }
        }]
      });
TracySchloss
Honored Contributor

I was hoping for something obvious I wasn't seeing, but at least there's a way to have both. 

0 Kudos