Start/stop edit layers

1423
5
12-06-2012 01:11 AM
PatrickChapuis
New Contributor II
ArcGIS for Server 10.1
ArcGIS API for JavaScript 3.2

Hi,

I need to start and stop editing layers. In my application, I can show and hide the editor widget (esri.dijit.editing.Editor) but, after has been started the first time, I cannot stop to edit features.

Here, the using process:
1- start editor
2- click on a feature : I got a popup and I can edit the geometry (vertices, size, ...)
3- stop editor
4- click on a different feature (or the same one), I can still edit the geometry.

Here, the ways to correct it I tried:
- layer.setEditable(false) => "FeatureLayer:setEditable - this functionality is not yet supported for layer in a feature service"
- destroy the editor or the template picker by using many ways  => inefficient
- start/stop the editor object => no way to do (activate/deactivate method don't exist)

Any idea?
0 Kudos
5 Replies
JohnGrayson
Esri Regular Contributor
I haven't tested this with the latest api, but try this:

editor._updateCurrentFeature(dojo.hitch(this,function(){
  editor._clearSelection(false);
}));
0 Kudos
PatrickChapuis
New Contributor II
Hi, thanks but it doesn't work. I tried to call your code when I shutdown the editor but maybe should I do it when I click on my feature?
0 Kudos
PatrickChapuis
New Contributor II
And, for information, this method exists : myEditor.stopEditing()

From /esri/dijit/editing/Editor.js
stopEditing : function(_6) {
 this._updateCurrentFeature(_2.hitch(this,
  function() {
   this._clearSelection(false);
   _6 && _6();
  }));
},



It seems it need a variable but I can't find which kind of
CarlosLopez9
New Contributor

Hi Patrick, how did you know of the existence of stopEditing() and _disableMapClickHandler() method?. Those methods don´t exist in the javascript api Editor | API Reference | ArcGIS API for JavaScript 3.20 . Excuse my English and I appreciate your response. 

0 Kudos
PatrickChapuis
New Contributor II
Ok, after a long time looking in the compiled code, it seems this solution work

Deactivate :
editorWidget.stopEditing(false);
editorWidget._disableMapClickHandler();

Activate :
editorWidget._enableMapClickHandler();

Be carefull to not call _enableMapClickHandler twice

My code:
//var editModeIsEdit (bool) true|false => editing session ?
function manageEditor(){
 if(editModeIsEdit){
  if(editorWidget!=undefined){
   editorWidget._disableMapClickHandler();
   editorWidget._enableMapClickHandler();
  }
 }else{
  if(templatePicker!=undefined){
   templatePicker.clearSelection(false);
  }
  if(editorWidget!=undefined){
   editorWidget.stopEditing(false);
   editorWidget._disableMapClickHandler();
  }
 }
}