Cancel/undo edit - only specific or last edit

478
3
06-09-2011 06:25 AM
PaulHedlund
New Contributor II
Using the Silverlight editor is it possible to undo the last edit or a specific edit without affecting the other edits that have not been saved yet?

Here are the steps:
1. Make several edits but do not save (autosave off)
2. Make another edit
3. Undo the edit in #2, but do not mess with edits in #1
4. Then save edits (in code or via editorwidget save button in users case).

'This code will undo all edits, but I want just a specific edit
'---------------
        Dim editor As Editor = TryCast(LayoutRoot.Resources("SplitEditor"), Editor)
        For Each graphicsLayer As GraphicsLayer In editor.GraphicsLayers
            If TypeOf graphicsLayer Is FeatureLayer Then
                Dim featureLayer As FeatureLayer = TryCast(graphicsLayer, FeatureLayer)
                If featureLayer.HasEdits Then
                    featureLayer.Update()
                End If

            End If
        Next graphicsLayer
'---------------
0 Kudos
3 Replies
JenniferNery
Esri Regular Contributor
If you are doing geometry change, in v2.2, you can use EditGeometry that will have an undo/redo stack. 

Also in v2.2, there is public methods UndoEdits() to undo all edits from last save and UndoEdits(Graphic g) to undo edits on a specific graphic. This includes attribute change.

In earlier versions, you have to implement your own undo/redo by remembering a graphics' previous state before the edit.
0 Kudos
ErosSy
by
New Contributor
If you are doing geometry change, in v2.2, you can use EditGeometry that will have an undo/redo stack.  

Also in v2.2, there is public methods UndoEdits() to undo all edits from last save and UndoEdits(Graphic g) to undo edits on a specific graphic. This includes attribute change. 

In earlier versions, you have to implement your own undo/redo by remembering a graphics' previous state before the edit.


I am using EditorWidget then I'm trying to edit a graphic using Edit Geometry icon there.
but.. I can't find the undo/redo functionality.

One more thing, let say it may possible to undo/redo in the case of geometry change.
How about other operations like Adding, Deleting a graphic?
Is there a necessity to implement our own undo/redo by remembering the states?

note: I am using WPF not Silverlight but I think it almost the same.
0 Kudos
JenniferNery
Esri Regular Contributor
EditorWidget use Editor.EditVertices command which does not expose Undo/Redo.

I was referring to this class: http://help.arcgis.com/en/webapi/silverlight/apiref/ESRI.ArcGIS.Client~ESRI.ArcGIS.Client.EditGeomet.... Undo/Redo is only for updates made to the geometry.

If you have AutoSave=False, you can look at calling FeatureLayer.UndoEdits()
http://help.arcgis.com/en/webapi/silverlight/apiref/ESRI.ArcGIS.Client~ESRI.ArcGIS.Client.FeatureLay.... For Redo(), you can call FeatureLayer.Update() http://help.arcgis.com/en/webapi/silverlight/apiref/ESRI.ArcGIS.Client~ESRI.ArcGIS.Client.FeatureLay...
0 Kudos