Select to view content in your preferred language

Editor Widget - onDelete event handler

2924
8
08-09-2012 02:23 AM
MostafaFouly
Emerging Contributor
i would like to ask if there's an event handler for deleting a feature in the Editor Widget? i know that it should be straightforward but i've been looking over esri apis help but couldn't find it!

it should be something like that but it doesn't work
dojo.connect(editorWidget,"onDelete",function(feature)

in the Attribute Inspector this event handler exists, but when i tried to implement it in the Editor Widget it didn't work, i mean when i delete a feature the onDelete isn't fired.

thanks for your help!
0 Kudos
8 Replies
ReneRubalcava
Esri Frequent Contributor
I'm not even sure what events the editor emits, if any, but the FeatureLayer has an "onEditsComplete" that will let you know what was deleted.

http://help.arcgis.com/EN/webapi/javascript/arcgis/help/jsapi/featurelayer.htm#onEditsComplete
0 Kudos
PatrickChapuis
Emerging Contributor
API JS 3.0
ArcGIS 10.1
Oracle 11g

I have a similar issue and maybe my question will answers yours.

I have to intercept objects to add, update or delete before they are sent to server. Because I have to authorize each edit and 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. I can modify or reset adds and updates but there is no way to reset the deletes.

I tried, without success:
delete deletes;
deletes = undefined;
deletes = new Array();


It seems impossible to cancel the call to applyEdit (it's a REST request send to the server).

A solution exists : to put a personal event on the delete button instead of the default one. This event would call a function wich would call applyEdits or not. But, this is not a solution if use the cut tool (my case) because updates and deletes are used and you not press a button but draw in the map.

I cannot believe there is no way to cancel a delete before it is sent to the server.

Maybe it will help to solve your problem but I think my situation is close so if someone have an idea.
0 Kudos
MostafaFouly
Emerging Contributor
I'm not even sure what events the editor emits, if any, but the FeatureLayer has an "onEditsComplete" that will let you know what was deleted.

http://help.arcgis.com/EN/webapi/javascript/arcgis/help/jsapi/featurelayer.htm#onEditsComplete


actually i'm using the "onEditsComplete" but the point is i lose the pointer for the deleted point, i managed to get a pointer to it before it's deleted but still having some other errors and conflicts with the update function.

i couldn't find any onDelete event handler for the editor!
0 Kudos
MostafaFouly
Emerging Contributor
API JS 3.0
ArcGIS 10.1
Oracle 11g

I have a similar issue and maybe my question will answers yours.

I have to intercept objects to add, update or delete before they are sent to server. Because I have to authorize each edit and 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. I can modify or reset adds and updates but there is no way to reset the deletes.

I tried, without success:
delete deletes;
deletes = undefined;
deletes = new Array();


It seems impossible to cancel the call to applyEdit (it's a REST request send to the server).

A solution exists : to put a personal event on the delete button instead of the default one. This event would call a function wich would call applyEdits or not. But, this is not a solution if use the cut tool (my case) because updates and deletes are used and you not press a button but draw in the map.

I cannot believe there is no way to cancel a delete before it is sent to the server.

Maybe it will help to solve your problem but I think my situation is close so if someone have an idea.


i tried the solution that you provided but unfortunately it's not working with me because i didn't create the delete button myself to be able to handle its event. so i'm using featureLayer.onEditsComplete event handler and check if the deletes parameter's length is greater than zero.

i am working on the update method now, i tried out the "onBeforeApplyEdits" event handler to get the value before and after being updated, but the result is the same, in other words i wasn't able to save the original value before updating it.

i checked the attribute inspector and it works properly, but i couldn't mix the functionality of both the editorWidget and the attributeInspector, it should look like the following:
dojo.connect(editorWidget, "onAttributeChange", function (feature, fieldName, newFieldValue)

did you manage to save the original values before the changes being applied?

my point is that i want to save all the operations to the UndoManager to be able to execute the undo/redo method
0 Kudos
PatrickChapuis
Emerging Contributor
Did you try to do this :

dojo.connect(myLayer, "onBeforeApplyEdits", saveValues);
function saveValues(adds,updates,deletes) {
 /** Treatements **/
}


I just tried and it seems to work

And, I found a shameful solution for my problem: http://forums.arcgis.com/threads/64501-Control-or-reset-arrays-of-graphics-before-applyEdits?p=22348...
0 Kudos
MostafaFouly
Emerging Contributor
my issue is that i want in the onDelete event handler to call the layer.applyEdits(...) passing my own parameters. so if i used the "onBeforeApplyEdits" it's going to be an infinite loop.

that's why i wonder if somebody knows how to handle the EditorWidget onDelete event
0 Kudos
KevinGooss
Regular Contributor
Don't have much in the way of an answer but i'm struggling with a similar issue.
I want to provide rollback support for my users when they edit in my js map app.
I have read the it can be done but must be implemented at the client level.
Is there something like a guid that esri passed back when a successful edit is done?
Or do i have to remember the edit to support undo?
I see exampled of redo/undo but they are always for client-side graphics and not for true feature editing.
0 Kudos
KellyHutchins
Esri Frequent Contributor
Kevin,

This sample shows how to use the UndoManager and the FeatureLayer onEditsComplete event to provide undo/redo capability to an editing application:

http://help.arcgis.com/en/webapi/javascript/arcgis/demos/ed/ed_undoRedo.html
0 Kudos