EditorViewModel

AMD: require(["esri/widgets/Editor/EditorViewModel"], (EditorVM) => { /* code goes here */ });
ESM: import EditorVM from "@arcgis/core/widgets/Editor/EditorViewModel.js";
Class: esri/widgets/Editor/EditorViewModel
Inheritance: EditorViewModel Accessor
Since: ArcGIS Maps SDK for JavaScript 4.11

Provides the logic for the Editor widget.

See also
Example
const editor = new Editor({
  viewModel: { // autocasts as new EditorViewModel
    layerInfos: [{
      layer: featureLayer,
      deleteEnabled: false // disables deleting features
    }]
  }
});

Constructors

new EditorViewModel(properties)
Parameter
properties Object
optional

See the properties for a list of all the properties that may be passed into the constructor.

Property Overview

Any properties can be set, retrieved or listened to. See the Working with Properties topic.
Show inherited properties Hide inherited properties
Name Type Summary Class
CreateWorkflow|CreateFeaturesWorkflow|UpdateWorkflow

A property indicating the current active workflow.

more details
EditorViewModel
String

An array of string values which specifies what end users are allowed to edit.

more details
EditorViewModel
AttachmentsViewModel

The AttachmentsViewModel for supporting the editor widget.

more details
EditorViewModel
Boolean

Convenience property that reads whether there are any editable layers that support the create-features workflow.

more details
EditorViewModel
Boolean

Convenience property that reads whether there are any editable layers that support the update workflow.

more details
EditorViewModel
String

The name of the class.

more details
Accessor
Collection<EditableItem>

A read-only collection of editable item objects that match the feature being updated.

more details
EditorViewModel
Object[]

An array of objects containing information specific to any failed editing operations.

more details
EditorViewModel
FeatureFormViewModel

The FeatureFormViewModel for supporting the editor widget.

more details
EditorViewModel
FeatureTemplatesViewModel

The FeatureTemplatesViewModel for supporting the editor widget.

more details
EditorViewModel
SketchLabelOptions

Options to configure the labels shown next to each segment of the geometry being created or updated.

more details
EditorViewModel
LayerInfo[]

An array of editing configurations for individual layers.

more details
EditorViewModel
SketchViewModel

The SketchViewModel for supporting the editor widget.

more details
EditorViewModel
SnappingOptions

The SnappingOptions for sketching.

more details
EditorViewModel
String

The widget's state.

more details
EditorViewModel
Boolean

Indicates if there is at least one edit request being processed.

more details
EditorViewModel
SketchTooltipOptions

Options to configure the tooltip shown next to the cursor when creating or updating graphics.

more details
EditorViewModel
MapView|SceneView

A reference to the MapView or SceneView.

more details
EditorViewModel

Property Details

A property indicating the current active workflow. This is either CreateFeaturesWorkflow or UpdateWorkflow.

See also
allowedWorkflows String

An array of string values which specifies what end users are allowed to edit. For example, a feature layer with full editing privileges may be available. But you may only want the end user to have the ability to update existing features. Set the allowedWorkflows to only update.

Possible Value Description
create This allows the end user to create a new individual feature in the feature service. (deprecated as of 4.23, use create-features as noted below.)
create-features This allows the end user to create either individual or continuous features in the feature service. (Since 4.23)
update This allows the end user to update and/or delete features in the feature service.

These workflows are only enabled if the feature service allows these operations.

Possible Values:"create-features"|"create"|"update"

attachmentsViewModel AttachmentsViewModel

The AttachmentsViewModel for supporting the editor widget. Attachment editing is enabled by default if the layer has support for it.

canCreate Booleanreadonly

Convenience property that reads whether there are any editable layers that support the create-features workflow.

canUpdate Booleanreadonly

Convenience property that reads whether there are any editable layers that support the update workflow.

declaredClass Stringreadonly inherited

The name of the class. The declared class name is formatted as esri.folder.className.

editableItems Collection<EditableItem>readonly

A read-only collection of editable item objects that match the feature being updated.

failures Object[]readonly

An array of objects containing information specific to any failed editing operations. In addition to the error(s), options to retry() or cancel() are provided.

Property
error Error

The read-only error message.

featureFormViewModel FeatureFormViewModel

The FeatureFormViewModel for supporting the editor widget.

featureTemplatesViewModel FeatureTemplatesViewModel

The FeatureTemplatesViewModel for supporting the editor widget.

Since: ArcGIS Maps SDK for JavaScript 4.24

Options to configure the labels shown next to each segment of the geometry being created or updated.

Known Limitation

Sketch labels are currently only supported when working with a SceneView.

layerInfos LayerInfo[]

An array of editing configurations for individual layers.

For example, if you have an editable feature layer but do not want the end user to do any type of editing, you can limit this by setting the enabled property to false.

Example
const editorViewModel = new EditorViewModel({
  layerInfos: [{
    view: view,
    layer: featureLayer, // pass in the feature layer,
    formTemplate:  { // autocastable to FormTemplate
      elements: [
        { // autocastable to FieldElement
          type: "field",
          fieldName: "fulladdr",
          label: "Full Address"
        }
      ]
    },
    enabled: true, // default is true, set to false to disable editing functionality
    addEnabled: true, // default is true, set to false to disable the ability to add a new feature
    updateEnabled: false // default is true, set to false to disable the ability to edit an existing feature
    deleteEnabled: false // default is true, set to false to disable the ability to delete features
  }]
});
sketchViewModel SketchViewModel

The SketchViewModel for supporting the editor widget.

snappingOptions SnappingOptionsautocast
Since: ArcGIS Maps SDK for JavaScript 4.19

The SnappingOptions for sketching. It supports self and feature snapping.

state Stringreadonly

The widget's state. Possible values are in the table below.

Value Description
ready Dependencies are met and has valid property values.
disabled Dependencies are missing and cannot provide valid inputs.
editing-new-feature The Editor is currently editing (creating) a new feature and applies only to the deprecated CreateWorkflow.
editing-existing-feature The Editor is currently editing an existing feature.
awaiting-update-feature-candidate The period when the application is awaiting the user's input after clicking update and multiple features are returned. Specify the feature to update.
awaiting-feature-creation-info This is the first step in the create-features workflow. A CreationInfo is required.
awaiting-feature-to-update This is the first step in the update workflow. A feature is required.
awaiting-feature-to-create The waiting period for when a feature is created before attribute/geometry edits can be performed.
adding-attachment If currently editing-existing-feature and adding an attachment to an existing feature.
editing-attachment If currently editing-existing-feature and updating an existing attachment to an existing feature.
creating-features The Editor is currently creating multiple features.

Possible Values:"adding-attachment"|"awaiting-feature-creation-info"|"awaiting-feature-to-create"|"awaiting-feature-to-update"|"awaiting-update-feature-candidate"|"creating-features"|"disabled"|"editing-attributes"|"editing-attachment"|"editing-existing-feature"|"editing-new-feature"|"awaiting-update-feature-candidate"|"ready"

syncing Booleanreadonly

Indicates if there is at least one edit request being processed.

Since: ArcGIS Maps SDK for JavaScript 4.24

Options to configure the tooltip shown next to the cursor when creating or updating graphics.

A reference to the MapView or SceneView. This view provides the editable layers for the Editor widget and is required when instantiating the widget.

Method Overview

Show inherited methods Hide inherited methods
Name Return Type Summary Class

Adds one or more handles which are to be tied to the lifecycle of the object.

more details
Accessor
Promise<void>

Cancels any active workflow.

more details
EditorViewModel
Promise<void>

This is applicable if there is an active update workflow with an active child workflow.

more details
EditorViewModel
Boolean

Returns true if a named group of handles exist.

more details
Accessor

Removes a group of handles owned by the object.

more details
Accessor
Promise<void>

Initiates the CreateFeaturesWorkflow by displaying the panel where feature creation begins.

more details
EditorViewModel
Promise<void>

Initiates the CreateFeaturesWorkflow by displaying the FeatureTemplates panel.

more details
EditorViewModel
Promise<void>

Initiates the CreateWorkflow by displaying the panel where feature creation begins.

more details
EditorViewModel
Promise<void>

This method starts the CreateWorkflow where it waits for the feature to be selected.

more details
EditorViewModel
Promise<void>

Initiates the CreateWorkflow by displaying the FeatureTemplates panel.

more details
EditorViewModel
Promise<void>

Starts the update workflow at the feature geometry and attribute editing panel.

more details
EditorViewModel
Promise<void>

Starts the update workflow using the current selected feature.

more details
EditorViewModel
Promise<void>

Starts the Editor workflow where it waits for multiple features to be selected.

more details
EditorViewModel

Toggles the UpdateWorkflow.

more details
EditorViewModel

Method Details

addHandles(handleOrHandles, groupKey)inherited
Since: ArcGIS Maps SDK for JavaScript 4.25

Adds one or more handles which are to be tied to the lifecycle of the object. The handles will be removed when the object is destroyed.

// Manually manage handles
const handle = reactiveUtils.when(
  () => !view.updating,
  () => {
    wkidSelect.disabled = false;
  },
  { once: true }
);

this.addHandles(handle);

// Destroy the object
this.destroy();
Parameters
handleOrHandles WatchHandle|WatchHandle[]

Handles marked for removal once the object is destroyed.

groupKey *
optional

Key identifying the group to which the handles should be added. All the handles in the group can later be removed with Accessor.removeHandles(). If no key is provided the handles are added to a default group.

cancelWorkflow(){Promise<void>}

Cancels any active workflow.

Returns
Type Description
Promise<void> Resolves once the workflow is canceled.
deleteFeatureFromWorkflow(){Promise<void>}

This is applicable if there is an active update workflow with an active child workflow. In this case, this method deletes the feature associated with the active child workflow.

Returns
Type Description
Promise<void> Resolves once the active UpdateWorkflow is deleted.
See also
hasHandles(groupKey){Boolean}inherited
Since: ArcGIS Maps SDK for JavaScript 4.25

Returns true if a named group of handles exist.

Parameter
groupKey *
optional

A group key.

Returns
Type Description
Boolean Returns true if a named group of handles exist.
Example
// Remove a named group of handles if they exist.
if (obj.hasHandles("watch-view-updates")) {
  obj.removeHandles("watch-view-updates");
}
removeHandles(groupKey)inherited
Since: ArcGIS Maps SDK for JavaScript 4.25

Removes a group of handles owned by the object.

Parameter
groupKey *
optional

A group key or an array or collection of group keys to remove.

Example
obj.removeHandles(); // removes handles from default group

obj.removeHandles("handle-group");
obj.removeHandles("other-handle-group");
startCreateFeaturesWorkflowAtFeatureCreation(creationInfo){Promise<void>}
Since: ArcGIS Maps SDK for JavaScript 4.23

Initiates the CreateFeaturesWorkflow by displaying the panel where feature creation begins. This method takes a CreationInfo object containing the layer(s) and template(s) to use.

Parameter
creationInfo CreationInfo

An object containing information needed to create a new feature using the Editor widget. This object provides the feature template and layer for creating a new feature.

Returns
Type Description
Promise<void> Resolves when the CreateFeaturesWorkflow initiates and displays the panel where feature creation begins.
startCreateFeaturesWorkflowAtFeatureTypeSelection(){Promise<void>}
Since: ArcGIS Maps SDK for JavaScript 4.23

Initiates the CreateFeaturesWorkflow by displaying the FeatureTemplates panel.

Returns
Type Description
Promise<void> Resolves when the CreateFeaturesWorkflow is initiated and displays the FeatureTemplates panel.
startCreateWorkflowAtFeatureCreation(creationInfo){Promise<void>}
Deprecated since version 4.23. Instead use startCreateFeaturesWorkflowAtFeatureCreation.

Initiates the CreateWorkflow by displaying the panel where feature creation begins. This method takes a CreationInfo object containing the layer(s) and template(s) to use.

Parameter
creationInfo CreationInfo

An object containing information needed to create a new feature using the Editor widget. This object provides the feature template and layer for creating a new feature.

Returns
Type Description
Promise<void> Resolves when the CreateFeaturesWorkflow initiates and displays the panel where feature creation begins.
startCreateWorkflowAtFeatureEdit(feature){Promise<void>}
Deprecated since 4.23

This method starts the CreateWorkflow where it waits for the feature to be selected.

Parameter
feature Graphic

The feature to be edited.

Returns
Type Description
Promise<void> Resolves once the CreateWorkflow initiates, displays the panel where feature creation begins, and waits for the feature to be selected.
See also
startCreateWorkflowAtFeatureTypeSelection(){Promise<void>}
Deprecated since version 4.23. Instead use startCreateFeaturesWorkflowAtFeatureTypeSelection.

Initiates the CreateWorkflow by displaying the FeatureTemplates panel.

Returns
Type Description
Promise<void> Resolves when the CreateWorkflow is initiated and displays the FeatureTemplates panel.
See also
startUpdateWorkflowAtFeatureEdit(feature){Promise<void>}

Starts the update workflow at the feature geometry and attribute editing panel.

Parameter
feature Graphic

The feature to be updated.

Returns
Type Description
Promise<void> Resolves once the UpdateWorkflow initiates the feature geometry and attribute editing panel.
See also
startUpdateWorkflowAtFeatureSelection(){Promise<void>}

Starts the update workflow using the current selected feature.

Returns
Type Description
Promise<void> Resolves once the UpdateWorkflow is initiated using the current selected feature.
See also
startUpdateWorkflowAtMultipleFeatureSelection(){Promise<void>}

Starts the Editor workflow where it waits for multiple features to be selected.

Returns
Type Description
Promise<void> Resolves once the UpdateWorkflow is initiated as it waits for multiple features to be selected.
See also
toggleUpdateWorkflow()

Toggles the UpdateWorkflow.

Type Definitions

EditableItem

The editable item available within the map. All the properties returned within it are read-only.

Properties
layer FeatureLayer|SceneLayer|module/esri/layers/support/SubtypeSublayer

The layer associated with the editable item.

supports String

The workflow type that this item supports. Possible values are create, update, or delete.

hasAttachments Boolean

Indicates whether this layer has attachments on it.

geometryUpdatesEnabled Boolean

Indicates whether this layer enables or disables geometry updates.

attributeUpdatesEnabled Boolean

Indicates whether this layer supports attribute editing while in the update workflow.

attachmentsOnCreateEnabled Boolean

Indicates whether this layer supports the ability to work with attachments while creating features.

attachmentsOnUpdateEnabled Boolean

Indicates whether this layer supports the ability to work with attachments while updating or deleting features.

hasInvalidFormTemplate Boolean

Indicates whether this layer's formTemplate is invalid. For example, removing or deleting a field within the layer that is still referenced in its original way and not updating the coinciding template.

hasUnsupportedFields Boolean

Indicates whether this layer references unsupported field types. For example, there is currently no support for date-only, time-only, timestamp-offset.

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.