I'm having trouble setting a popup template for a feature layer. Based on the documentation I expected to be able define a PopupTemplate object, define the fieldInfos property and leave the content property null resulting in the popup displaying the fieldInfos as a table as documented here:
fieldInfos
is not set directly within the content
property, the popup will display whatever is set in the PopupTemplate.fieldInfos property. This must be defined using the fields popup element specification table.However, when I do this, the popup appears blanks:
I have to manually set the content property as follows to get the populate:
Am I doing something wrong or is the documentation incorrect?
Solved! Go to Solution.
Sam,
I think that the documentation could explain this a little better. You currently have to define the content as type fields if you are only providing the fieldInfos (lines 4-6).
// autocasts as new PopupTemplate()
var template = {
title: "Marriage in NY, Zip Code: {ZIP}",
content: [{
type:"fields"
}],
fieldInfos: [{
fieldName: "MARRIED_CY",
format: {
digitSeparator: true, // Use a comma separator for large numbers
places: 0 // Sets the number of decimal places to 0 and rounds up
}
}, {
fieldName: "NEVMARR_CY",
format: {
digitSeparator: true,
places: 0
}
}, {
fieldName: "DIVORCD_CY",
format: {
digitSeparator: true,
places: 0
}
}]
};
Sam,
I think that the documentation could explain this a little better. You currently have to define the content as type fields if you are only providing the fieldInfos (lines 4-6).
// autocasts as new PopupTemplate()
var template = {
title: "Marriage in NY, Zip Code: {ZIP}",
content: [{
type:"fields"
}],
fieldInfos: [{
fieldName: "MARRIED_CY",
format: {
digitSeparator: true, // Use a comma separator for large numbers
places: 0 // Sets the number of decimal places to 0 and rounds up
}
}, {
fieldName: "NEVMARR_CY",
format: {
digitSeparator: true,
places: 0
}
}, {
fieldName: "DIVORCD_CY",
format: {
digitSeparator: true,
places: 0
}
}]
};
Thanks rscheitlin, that was exactly the answer. Given that across the platform, the default popup is a table view that displays all visible fields - it would probably make sense for the API to assume this by default.