▾
import DynamicChoiceInput from "@arcgis/core/form/elements/inputs/DynamicChoiceInput.js";const DynamicChoiceInput = await $arcgis.import("@arcgis/core/form/elements/inputs/DynamicChoiceInput.js");- Inheritance
- DynamicChoiceInput→
SingleChoiceInput→ Input→ Accessor
- Since
- ArcGIS Maps SDK for JavaScript 5.2
The DynamicChoiceInput class defines the desired user interface for a dynamic choice group input. It lets users select a field value from a list of choices generated by an Arcade expression, rather than a fixed list. It is supported in both single and batch feature editing. Use a dynamic choice input when the available options depend on the feature being edited, values entered in other fields, or data queried from another layer or table.
This FieldElement.input is used in field elements that are set within a feature layer's formTemplate. This is displayed within the Editor.
To configure a dynamic choice input, set its choiceExpression to the name of an Arcade expression in the form template's FormTemplate.expressionInfos. The expression returns a dictionary containing a choices array, where each choice has a name for its display text and a code for the value stored in the field.
- Example
- // Creates a new dynamic choice input for a field element within a formconst dynamicChoiceInput = new DynamicChoiceInput({choiceExpression: dynamicChoiceExpression.name, // reference to the defined expressionnoValueOptionLabel: "No Value (null)", // label for the option representing a null valueshowNoValueOption: false, // whether to display the choice representing a null value (i.e., "No Value")});
Constructors
Constructor
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| properties | | |
Properties
| Property | Type | Class |
|---|---|---|
| | ||
| readonly inherited | ||
| inherited | ||
| inherited | ||
| readonly | "dynamic-choice" | |
choiceExpression
A reference to an Arcade expression that returns a dictionary. The dictionary should have a choices array of objects, with each object in the array having a name property that is the text displayed to the user, and a code property that is the value assigned to the field when that choice is selected.
- Example
- // Set the choice expression for the dynamic choice inputfieldElement.input = new DynamicChoiceInput({choiceExpression: dynamicChoiceExpression.name});const dynamicChoiceExpression = new ExpressionInfo({name: "dynamic-material-choices",title: "Dynamic material choices",expression:`var choices = [{ name: "Unknown", code: 0 },{ name: "Cast Iron - CAS", code: 83 },{ name: "Copper - COP", code: 84 },{ name: "Ductile Iron - DIP", code: 88 },{ name: "Polyvinyl Chloride - PVC", code: 94 },{ name: "Lead - LP", code: 109 }];return {choices: choices};`,returnType: "dictionary",});
noValueOptionLabel
The text used to represent a null value.
showNoValueOption
- Type
- boolean
Determines whether a null value option is displayed.
This only applies to fields that support null values.
- Default value
- true
Methods
| Method | Signature | Class |
|---|---|---|
| inherited static | fromJSON(json: any): any | |
| clone(): DynamicChoiceInput | | |
| inherited | toJSON(): any |
fromJSON
- Signature
-
fromJSON (json: any): any
Creates a new instance of this class and initializes it with values from a JSON object
generated from an ArcGIS product. The object passed into the input json
parameter often comes from a response to a query operation in the REST API or a
toJSON()
method from another ArcGIS product. See the Using fromJSON()
topic in the Guide for details and examples of when and how to use this function.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| json | A JSON representation of the instance in the ArcGIS format. See the ArcGIS REST API documentation for examples of the structure of various input JSON objects. | |
- Returns
- any
Returns a new instance of this class.
clone
- Signature
-
clone (): DynamicChoiceInput
Creates a deep clone of the DynamicChoiceInput class.
- Returns
- DynamicChoiceInput
A deep clone of the
DynamicChoiceInputinstance.
toJSON
- Signature
-
toJSON (): any
Converts an instance of this class to its ArcGIS portal JSON representation. See the Using fromJSON() guide topic for more information.
- Returns
- any
The ArcGIS portal JSON representation of an instance of this class.