Editor widget 4.15

826
4
Jump to solution
04-24-2020 11:22 AM
MKY
by
New Contributor III

I an using Editor widget 4.15 with update workflow.  I want to do additional pre-processing of the updated feature before it is posted (commit) to the feature layer. I could not figure out the best way to listen to an event when "Update" button is clicked.

0 Kudos
1 Solution

Accepted Solutions
AnneFitz
Esri Contributor

You can use the sketchViewModel.update event to see when the geometry is being edited (as they do in the Sketch Update Validation sample).

The editorViewModel.featureFormViewModel controls the Editor form - you should be able to use set featureFormViewModel.valid to false if the edited geometry is invalid, and that will disable the "update" button on the editor widget. 

I haven't tested this out yet, but hopefully that will get you going in the right direction! Let me know how it turns out.

View solution in original post

0 Kudos
4 Replies
AnneFitz
Esri Contributor

Hi Markos,

I'm not sure if this is exactly what you're looking for, but you could try watching the "state" property on the Editor.viewModel:

editor.viewModel.watch("state", function(
   newValue,
   oldValue,
   propertyName,
   target
) {
   console.log(
      propertyName + " changed from " + oldValue + " to " + newValue
   );
});

See it in action here: https://codepen.io/annefitz/pen/PoPjwoQ 

Observe the change in state in the console.

Hope this helps! 

Anne

MKY
by
New Contributor III

Anne, thank you.

I have the following workflow and not sure how to proceed.

In the editor tool I want to edit geometry and attribute. If the edited geometry is invalid, i want to disable the "update" button on the editor widget. If the geometry is valid, I have to update an attribute field (in code) based on the new geometry and its relationship to another feature layer.

I hope it makes sense.  by the way, I use the sample code for sketch update validation. Sketch update validation | ArcGIS API for JavaScript 4.15  for geometry validation

0 Kudos
AnneFitz
Esri Contributor

You can use the sketchViewModel.update event to see when the geometry is being edited (as they do in the Sketch Update Validation sample).

The editorViewModel.featureFormViewModel controls the Editor form - you should be able to use set featureFormViewModel.valid to false if the edited geometry is invalid, and that will disable the "update" button on the editor widget. 

I haven't tested this out yet, but hopefully that will get you going in the right direction! Let me know how it turns out.

0 Kudos
MKY
by
New Contributor III

Anne, Thank you for you guidance! I was able to validate and implement.