Editor Widget Events

1992
1
Jump to solution
03-15-2022 04:56 PM
BruceSchneider2
New Contributor II

Using ArcGIS API for JavaScript 4.x I am trying to create custom behavior for the Editor Widget. Specifically I want to watch for clicking the Add button on the create workflow or when clicking either Update or Delete on the update workflow. I am trying to use the editor.on() event handler, however, I am not seeing a list of events for the Editor widget. Other widgets, such as Search, have an Event Overview list (https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Editor.html#events-summar...) but there does not seem to be one for Editor (https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Editor.html#events-summar...).

A point in the right direction would be appreciated.

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
RodrigoAbril
New Contributor II

you need to use the .on or .watch in the editor.viewModel , there are 2 sub viewModels inside that too

editor
.viewModel.featureTemplatesViewModel
editor.viewModel.featureSketchViewModel


this will trigger on all editor states, you can check which event you need to trigger your custom code

editor.viewModel.watch("state", function (state) {
console.log(state);
});


or you can be more specific like this:

editor.viewModel.featureTemplatesViewModel.on("select", (x) => {
console.log(x);
});

 

View solution in original post

1 Reply
RodrigoAbril
New Contributor II

you need to use the .on or .watch in the editor.viewModel , there are 2 sub viewModels inside that too

editor
.viewModel.featureTemplatesViewModel
editor.viewModel.featureSketchViewModel


this will trigger on all editor states, you can check which event you need to trigger your custom code

editor.viewModel.watch("state", function (state) {
console.log(state);
});


or you can be more specific like this:

editor.viewModel.featureTemplatesViewModel.on("select", (x) => {
console.log(x);
});