Select to view content in your preferred language

How to cancel graphic change like Reshape,cut, union and editVertix?

985
7
11-16-2010 01:49 PM
XiujuZhou
Emerging Contributor
In my arcGIS API 2 for siliverlight application which uses ArcGIS server 10 services, I use editing tool to add new, edit graphics like Reshape,cut, union and editVertix. I need a tool/function to cancel the current change from one of those actions. How to do that? please help!! Thanks.
0 Kudos
7 Replies
JenniferNery
Esri Regular Contributor
If you will be using v2.1, executing CancelActive command of the Editor will undo changes made by the EditVertices command if it were the current active command.

Reshape, Cut and Union, however are done through GeometryService and are committed right away if you have AutoSave=true.

I suggest setting AutoSave=false, listen to Editor's EditCompleted event and see if the EditAction is Reshape/Cut/Union/EditVertices. You will have access to the Graphic that was modified and the layer it belongs to at this point. Therefore you can check whether this is the desired geometry change, before committing the changes to your server by calling layer.SaveEdits().
0 Kudos
XiujuZhou
Emerging Contributor
Jannifer, thanks for your help. AutoSave is set for my featureLayer. When calling editor's EditCompleted event, the graphic is saved already. I cannot stop save by writing any code in it.
0 Kudos
JenniferNery
Esri Regular Contributor
Yup, that is why I suggested in making AutoSave to false and just explicitly call SaveEdits() http://help.arcgis.com/en/webapi/silverlight/apiref/ESRI.ArcGIS.Client~ESRI.ArcGIS.Client.FeatureLay... when the geometry change seem correct 😛

This should give you a chance to undo or cancel the changes in the Editor's EditCompleted event.
0 Kudos
XiujuZhou
Emerging Contributor
Sorry I didn't explained clearly. what I tried to tell is that, I have set AutoSave to False to my feature layer. When calling Editor's editCompleted, the graphic is changed on
screen already, even though I have not saved it to feature Layer yet by running MyFeatureLayer.saveEdit. Which means, I think, the change is saved to a graphic layer or somewhere in memory at the moment of calling Editor's editCompleted, until run MyFeatureLayer.saveEdit, the change is going to save to feature layer from graphic layer or somewhere. How to make this change to be back to the original on the screen? I don't want to reload the feature layer by calling myFeatureLayer.update() to see the original one, otherwise, all changes to other features are going to be lost.

Yup, that is why I suggested in making AutoSave to false and just explicitly call SaveEdits() http://help.arcgis.com/en/webapi/silverlight/apiref/ESRI.ArcGIS.Client~ESRI.ArcGIS.Client.FeatureLay... when the geometry change seem correct 😛

This should give you a chance to undo or cancel the changes in the Editor's EditCompleted event.
0 Kudos
JenniferNery
Esri Regular Contributor
If you want to accept the change in geometry caused by Cut/Reshape/Union/EditVertices, you can explicitly call SaveEdits(). Otherwise to revert back to the old geometry, the only way is to call FeatureLayer.Update().

Another option is to use v2.1 RTM.  Like I said in my previous post, CancelActive command will also cancel edits made by EditVertices command if it were the active command and the changes were not yet commited. 

However, Cut/Reshape/Union does not cancel their edit with CancelActive command even with v2.1 RTM.  The reason is because, the GeometryService call performs this change instantaneously; unlike EditVertices where you have to click back on the feature to finalize the edit.  For this case, I would advise to do the first approach.
0 Kudos
XiujuZhou
Emerging Contributor
the problem is the graphic change is showing on the screen right after user's action and before save to feature layer by calling SaveEdits().
If you want to accept the change in geometry caused by Cut/Reshape/Union/EditVertices, you can explicitly call SaveEdits(). Otherwise to revert back to the old geometry, the only way is to call FeatureLayer.Update().

Another option is to use v2.1 RTM.  Like I said in my previous post, CancelActive command will also cancel edits made by EditVertices command if it were the active command and the changes were not yet commited. 

However, Cut/Reshape/Union does not cancel their edit with CancelActive command even with v2.1 RTM.  The reason is because, the GeometryService call performs this change instantaneously; unlike EditVertices where you have to click back on the feature to finalize the edit.  For this case, I would advise to do the first approach.
0 Kudos
JenniferNery
Esri Regular Contributor
While EditVertices is active, the edits on the graphic will show until you finalize the edit and call layer.Update() in EditCompleted event to retrieve the original graphic. To save the changes, you will not need to call layer.Update() but instead call layer.EndSaveEdits().
0 Kudos