popupUtils
require(["esri/support/popupUtils"], function(popupUtils) { /* code goes here */ });
esri/support/popupUtils
Various utils for working with Popup widget functionality.
Method Overview
Name | Return Type | Summary | Object | |
---|---|---|---|---|
FieldInfo[] | Creates an array of fieldInfo used for populating FieldsContent. more details | more details | popupUtils | |
FieldsContent | Creates fields content used for populating a PopupTemplate. more details | more details | popupUtils | |
PopupTemplate | Creates a popup template given the specified config information. more details | more details | popupUtils |
Method Details
Creates an array of fieldInfo used for populating FieldsContent.
Parameters:config FieldInfosConfigA configuration object containing properties for creating fieldInfo.
options CreatePopupTemplateOptionsoptionalOptions for creating the PopupTemplate.
Returns:Type Description FieldInfo[] An array of FieldInfo content used to popuplate the FieldsContent, which in turn is used to popuplate the PopupTemplate. By default, system fields, e.g. Shape__Area
andShape__Length
,OID
, etc, do not display.Example:// Sets the configuration for the popup template. // Each object in this array is autocast as an instance of esri/layers/support/Field const fields = [{ name: "NAME", alias: "Name", type: "string" }, { name: "County", alias: "County", type: "string" }, { name: "ALAND", alias: "Land", type: "double" }]; // This sets the options to ignore all fields of "date" type and sets two visible fields const templateOptions = { ignoreFieldTypes: ["date"], visibleFieldNames: new Set(["NAME", "ALAND"]) }; // Set the FieldInfo const fieldsConfig = {fields: fields}; // Create the FieldInfos const fieldInfos = popupUtils.createFieldInfos(fieldsConfig, templateOptions); // Sets the FieldsContent const fieldsContent = new FieldsContent({ fieldInfos: fieldInfos }); // Create the template and pass in the fields content const template = { title: "County Land", outFields: ["*"], content: [fieldsContent] }; // Set the feature layer's popup template featureLayer.popupTemplate = template;
- createFieldsContent(config, options){FieldsContent}
Creates fields content used for populating a PopupTemplate.
Parameters:config FieldInfosConfigA configuration object containing properties for creating FieldsContent.
options CreatePopupTemplateOptionsoptionalOptions for creating the PopupTemplate.
Returns:Type Description FieldsContent The fields
content used to popuplate the PopupTemplate. This content contains an array of FieldInfo.Example:// Sets the configuration for the popup template. // Each object in this array is autocast as an instance of esri/layers/support/Field const fields = [{ name: "NAME", alias: "Name", type: "string" }, { name: "County", alias: "County", type: "string" }, { name: "ALAND", alias: "Land", type: "double" }]; // This sets the options to ignore all fields of "date" type and sets two visible fields const templateOptions = { ignoreFieldTypes: ["date"], visibleFieldNames: new Set(["NAME", "ALAND"]) }; // Set the FieldInfo const fieldsConfig = {fields: fields}; // Create the Fields Content const fieldsContent = popupUtils.createFieldsContent(fieldsConfig, templateOptions); // Create the template and pass in the fields content const template = { title: "County Land", outFields: ["*"], content: [fieldsContent] }; // Set the feature layer's popup template featureLayer.popupTemplate = template;
- createPopupTemplate(config, options){PopupTemplate}
Creates a popup template given the specified config information.
Parameters:config ConfigA configuration object containing properties for creating a PopupTemplate.
options CreatePopupTemplateOptionsoptionalOptions for creating the PopupTemplate.
Returns:Type Description PopupTemplate The popup template, or null
if no fields are set.Example:// Sets the configuration for the popup template. // Each object in this array is autocast as an instance of esri/layers/support/Field const fields = [{ name: "NAME", alias: "Name", type: "string" }, { name: "County", alias: "County", type: "string" }, { name: "ALAND", alias: "Land", type: "double" }]; const config = { displayField: "County", fields: fields, title: "County land" }; // This sets the options to ignore all fields of "date" type and sets two visible fields const templateOptions = { ignoreFieldTypes: ["date"], visibleFieldNames: new Set(["NAME", "ALAND"]) }; const template = popupUtils.createPopupTemplate(config, templateOptions); featureLayer.popupTemplate = template;
Type Definitions
- Config
A configuration object containing properties for creating a PopupTemplate.
- Properties:
- optionaldisplayField String
The display field.
title StringThe title for the PopupTemplate.
optionaleditFieldsInfo EditFieldsInfoThe fields that record who adds or edits data in the feature service and when the edit is made.
The fields displayed within the PopupTemplate.
optionalobjectIdField StringThe object id field.
Example:// Sets the configuration for the popup template. // Each object in this array is autocast as an instance of esri/layers/support/Field const fields = [{ name: "NAME", alias: "Name", type: "string" }, { name: "County", alias: "County", type: "string" }, { name: "ALAND", alias: "Land", type: "double" }]; const config = { displayField: "County", fields: fields, title: "County land" };
- CreatePopupTemplateOptions
Options for creating the PopupTemplate.
- Properties:
optional An array of field types to ignore when creating the popup. System fields such as
Shape_Area
andShape_length
, in addition togeometry
,blob
,raster
,guid
andxml
field types are automatically ignored.optional An array of field names set to be visible within the PopupTemplate.
Example:// This sets the options to ignore all fields of "date" type and sets two visible fields const templateOptions = { ignoreFieldTypes: ["date"], visibleFieldNames: new Set(["NAME", "ALAND"]) };
- FieldInfosConfig
A configuration object containing field properties for creating FieldsContent for a PopupTemplate.
- Properties:
- optionaleditFieldsInfo EditFieldsInfo
The fields that record who adds or edits data in the feature service and when the edit is made.
The fields displayed within the PopupTemplate.
optionalobjectIdField StringThe object id field.
Example:// Sets the configuration for the popup template. // Each object in this array is autocast as an instance of esri/layers/support/Field const fieldsConfig = [{ name: "NAME", alias: "Name", type: "string" }, { name: "County", alias: "County", type: "string" }, { name: "ALAND", alias: "Land", type: "double" }];