Prevent ApplyEdits using editor widget

3805
9
Jump to solution
03-16-2016 11:13 AM
RobertScheitlin__GISP
MVP Emeritus

I want to prevent the editor Widget from adding a new feature to a FeatureLayer when a certain condition is not meet using the before-apply-edits event. But so far I can not figure out how to cancel/prevent the ApplyEdits from going through. Does anyone have any insight on this?

0 Kudos
1 Solution

Accepted Solutions
Vara_PrasadM_S
Occasional Contributor II

Hi Robert,

I got some time to implement and check my idea mentioned above. Unfortunately, it did not work. I got below useful link. Please have a look at it.

arcgis server - Prevent Editor Widget auto save - Geographic Information Systems Stack Exchange

Thanks & Regards,

Vara Prasad.

View solution in original post

9 Replies
Vara_PrasadM_S
Occasional Contributor II

Hi Robert,

Try attaching "before-apply-edits" event on FeatureLayer which you are trying to edit using Edit Widget and take decision which features have to be added/updated/deleted and then remove/update the graphic objects of the event callback arrays and see if it works.

In this "before-apply-edits" call back, if you do not want to progress with the edits, then you need to raise any exception something like "throw new Error("Edits are not required");"

Thanks & Regards,

Vara Prasad.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Vara, yep I had tried that and may other attempts as well and nothing I did prevented the feature from being added to the FL. I will look at the provided link to see if there is anything there. Thanks though.

0 Kudos
AbhinavSharma
New Contributor III

Hi Robert,

I understand that this is an old thread, but I was wondering if you ever found a solution that does not require editing the applyEdits method.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Unfortunately no.

0 Kudos
Vara_PrasadM_S
Occasional Contributor II

Hi Robert,

I got some time to implement and check my idea mentioned above. Unfortunately, it did not work. I got below useful link. Please have a look at it.

arcgis server - Prevent Editor Widget auto save - Geographic Information Systems Stack Exchange

Thanks & Regards,

Vara Prasad.

AbhinavSharma
New Contributor III

I ended up getting a cancel and apply button working by deep cloning the selected features (ie copying the original values) from before the edits, then if the user makes a change and it autosaves I have a clone of the original features still available should they choose to cancel. If they hit the cancel button I then use applyEdits again but this time pass the original features from the deep clone. Which essentially reverts the layer back to before the edit.

VIKRANTKRISHNA
New Contributor III

Hello All,

              I am facing similar problem. I have to use editor widget as part of my application, and once user draws a shape on the map, I need to calculate some field values using another geoprocessing task.

I could wait for original applyEdits task to finish, and then then calculate the new field values, and then applyEdits again ( and also putting a condition to stop recursion). This method does the job behind the scene, but doesn't show the calculated values in the popup window that comes after editing using editor widget.

This has become a major bottleneck for our project.               

0 Kudos
AbhinavSharma
New Contributor III

Are you able to use the before-apply-edits event to make your changes and then applyEdits within that event?

0 Kudos
VIKRANTKRISHNA
New Contributor III

No, I just used the edits-complete event of feature layer, capture the ObjectId of edited feature, query the feature layer for the updated feature, created a temporary feature layer and reapply edit. I could use the original feature layer to apply edits again, and some condition that it doesn't go in the infinite loop.

Problem I am facing is that popup window that shows up with the editor widget only shows edits from first applyEdit operation. I can't find a way to show second applyEdits results , without closing popup, refreshing layer and reopening popup.

0 Kudos