require(["esri/widgets/Editor/EditorViewModel"], function(EditorVM) { /* code goes here */ });
Class: esri/widgets/Editor/EditorViewModel
Inheritance: EditorViewModel Accessor
Since: ArcGIS API for JavaScript 4.11

Provides the logic for the Editor widget.

See also:
Example:
var 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.
NameTypeSummaryClass
Workflow

A property indicating the current active workflow.

more details
more detailsEditorViewModel
String[]

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

more details
more detailsEditorViewModel
Boolean

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

more details
more detailsEditorViewModel
Boolean

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

more details
more detailsEditorViewModel
String

The name of the class.

more details
more detailsAccessor
Collection<EditableItem>

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

more details
more detailsEditorViewModel
Object[]

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

more details
more detailsEditorViewModel
FeatureFormViewModel

The FeatureFormViewModel for supporting the editor widget.

more details
more detailsEditorViewModel
FeatureTemplatesViewModel

The FeatureTemplatesViewModel for supporting the editor widget.

more details
more detailsEditorViewModel
LayerInfo[]

An array of editing configurations for individual layers.

more details
more detailsEditorViewModel
SketchViewModel

The SketchViewModel for supporting the editor widget.

more details
more detailsEditorViewModel
String

The widget's state.

more details
more detailsEditorViewModel
Boolean

When true, there is at least one edit request being processed.

more details
more detailsEditorViewModel
MapView

A reference to the MapView.

more details
more detailsEditorViewModel

Property Details

activeWorkflow Workflowreadonly

A property indicating the current active workflow.

See also:
allowedWorkflows String[]

An array of string values which specifies what end users are allowed 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 ValueDescription
createIndicated in the widget via the Add feature option. This allows the end user to create new features in the feature service.
updateIndicated in the widget via the Edit feature option. 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. For example, if a feature service is only enabled to allow updates, 'Add features' is not enabled.

canCreate Booleanreadonly

Convenience property that reads whether there are any editable layers that support the create 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 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 readonly error message.

featureFormViewModel FeatureFormViewModel

The FeatureFormViewModel for supporting the editor widget.

featureTemplatesViewModel FeatureTemplatesViewModel

The FeatureTemplatesViewModel for supporting the editor widget.

layerInfos LayerInfo[]

An array of editing configurations for individual layers.

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 editor = new Editor({
  layerInfos: [{
    layer: featureLayer, // pass in the feature layer
    fieldConfig: [ // Specify which fields to configure
    {
      name: "fulladdr",
      label: "Full Address"
    },
    {
      name: "neighborhood",
      label: "Neighborhood"
    }],
    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.

state Stringreadonly

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

ValueDescription
readyDependencies are met and has valid property values.
disabledDependencies are missing and cannot provide valid inputs.
editing-new-featureThe Editor is currently editing (creating) a new feature.
editing-existing-featureThe Editor is currently editing an existing feature.
awaiting-update-feature-candidateThe 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-infoThis is the first step in the create workflow. A CreationInfo is required.
awaiting-feature-to-updateThis is the first step in the update workflow. A feature is required.
awaiting-feature-to-createThe waiting period for when a feature is created beforte attribute/geometry edits can be performed.
Default Value:disabled
syncing Booleanreadonly

When true, there is at least one edit request being processed.

view MapView

A reference to the MapView. This view provides the editable layers for the Editor widget.

Method Overview

NameReturn TypeSummaryClass

Cancels any active workflow.

more details
more detailsEditorViewModel

This is applicable if there is an active update workflow.

more details
more detailsEditorViewModel

Initiates the create workflow by displaying the panel where feature creation begins.

more details
more detailsEditorViewModel

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

more details
more detailsEditorViewModel

Initiates the create workflow by displaying the FeatureTemplates panel.

more details
more detailsEditorViewModel

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

more details
more detailsEditorViewModel

Starts the update workflow using the current selected feature.

more details
more detailsEditorViewModel

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

more details
more detailsEditorViewModel

Method Details

cancelWorkflow()

Cancels any active workflow.

deleteFeatureFromWorkflow()

This is applicable if there is an active update workflow. If so, this method deletes the workflow feature.

startCreateWorkflowAtFeatureCreation(creationInfo)

Initiates the create workflow 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.

startCreateWorkflowAtFeatureEdit(feature)

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

Parameter:
feature Graphic

The feature to be updated.

startCreateWorkflowAtFeatureTypeSelection()

Initiates the create workflow by displaying the FeatureTemplates panel.

startUpdateWorkflowAtFeatureEdit(feature)

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

Parameter:
feature Graphic

The feature to be updated.

startUpdateWorkflowAtFeatureSelection()

Starts the update workflow using the current selected feature.

startUpdateWorkflowAtMultipleFeatureSelection()

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

Type Definitions

EditableItem

The editable item available within the map.

Properties:

Read-only The feature layer associated with the editable item.

supports String

Read-only The workflow type that this item supports. Can be either, update or create.

API Reference search results

NameTypeModule
Loading...