Select to view content in your preferred language

Control or reset arrays of graphics before applyEdits

600
1
08-13-2012 02:27 AM
PatrickChapuis
Emerging Contributor
API JS 3.0
ArcGIS 10.1
Oracle 11g


I have to intercept objects to add, update or delete before they are sent to server. Because I have to authorize each edit or complete the attributes before they are applied to database.

The featureLayer get an event called onBeforeApplyEdits fired just before the applyEdits function.

This event gives 3 arrays of Graphic : adds, updates and deletes. The attributes of adds and updates can be modified but it seems there is no way to reset one of the 3 arrays in the call of applyEdits (REST request send to the server).

Does anybody knows a way to stop this call? Or maybe to set a check method? I cannot believe there is no way to cancel a delete before it is sent to the server.

Note : I cannot just put an event to my delete button. There is too many action wich calls applyEdits

Thanks by advance
0 Kudos
1 Reply
PatrickChapuis
Emerging Contributor
Ok, I have a solution: throw an error. It's really bad but it works.

dojo.connect(layer, "onBeforeApplyEdits", prepareApplyEdits);
function prepareApplyEdits(adds,updates,deletes) {
 var ok = true;
 if(adds==undefined && updates==undefined && deletes!=undefined){
  if(confirm("Do you really want to delete those elements?")){
                        /** treatement for attributes **/
  }else{
   ok=false;
  }
 }
 if(!ok){
  layer.clearSelection();
  throw new Error();
 }
}


I'm really ashamed but it's the only way I found. If anybody has a better idea, he can throw me the rock (or another solution)
0 Kudos