Select to view content in your preferred language

Undo edits of the EditorWidget

3092
12
08-05-2010 01:20 AM
MannusEtten
Emerging Contributor
the editor widget is a cool control to easy add new features and fill in the attributes. So we want to use this control. Our requirement to fulfill is to check the new feature after drawing.

The new graphic must be checked if it intersects with a certain other shape. We created a webservice for this functionality. So the check is no problem. But if the check say "editing on this place is not allowed" I would like to cancel the edit.

I implemented logic in the EditorWidget.Edit_Completed and FeatureLayer_BeginEditing event handlers. These handlers do have a input parameter EditAction. In both event handlers I set the EditAction to "Cancel". But still my features are drawn and saved to the geodatabase.

So how can I cancel the edit operation of the EditorWidget? Why does the Editor-class has an "undo" and the EditorWidget doesn't?
0 Kudos
12 Replies
JenniferNery
Esri Regular Contributor
The EditorWidget sets its own datacontext with an internal editor based on the properties you provide like Map, GeometryServiceUrl, Continuous, Layers, etc.. some of which are properties of the Editor as well.

If you set just the EditorWidget's datacontext to the editor, all of their common properties will get their default value. The widget does not check if its datacontext has been set to an editor and populate its properties based on this.

So if you would like an Editor defined as StaticResource, instead of setting EditorWidget's datacontext.. you can do GeometryServiceUrl={Binding Source={StaticResource MyEditor}, Path=GeometryServiceUrl}. In this case, you still need to grab the internal editor the EditorWidget created for itself to subscribe to its events.

Jennifer
0 Kudos
MannusEtten
Emerging Contributor
thanks for the solution now. I installed the trial edition of Blend too. I can update the layer when the edit is invalid so there are no edits. But in every case (valid/unvalid edit) the attribute-window will pop up.

So the property "showattributeonadd" is set to false. How can I control this window?
0 Kudos
JenniferNery
Esri Regular Contributor
I'm glad you have Blend now. It really helps play around with controls. You can customize any of ESRI toolkit here.

ShowAttributesOnAdd property when true will show a FeatureDataForm to display the attributes when you add a feature (EditAction is Add). Since you need to check if the add/edit is valid before actually adding the graphic, it will be best to set this property to false. If you wish to display the attributes on a successful add (one that you have marked as valid add), you can do your own call to display FeatureDataForm - this way you have more control of when this window is shown.

Jennifer
0 Kudos