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.
Solved! Go to Solution.
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.
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
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
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.
Anne, Thank you for you guidance! I was able to validate and implement.