Select to view content in your preferred language

SketchViewModel: disable deleting

161
2
Jump to solution
12-13-2024 01:33 AM
FernandaBarth_EsriPT
Esri Contributor

Hello,

I need to configure SketchViewModel to not allow deleting graphics but after a while searching it doesn't seem the sdk has this option, is there any way to disable deleting graphics? The 'delete' event also does not have the option to stopPropagation. 

The only work around I imagined is to do graphicsLayer.graphics.addMany(event.graphics) at the delete event, but not the best solution I think.

0 Kudos
1 Solution

Accepted Solutions
JoelBennett
MVP Regular Contributor

An alternate way would be to override the delete function:

sketchViewModel.delete = function() { };

 

The above would cause nothing to happen when the delete function is called.  If you needed to remove any graphics created by that module, you'd have to use some alternate means, like:

sketchViewModel.layer.removeAll();

View solution in original post

2 Replies
JoelBennett
MVP Regular Contributor

An alternate way would be to override the delete function:

sketchViewModel.delete = function() { };

 

The above would cause nothing to happen when the delete function is called.  If you needed to remove any graphics created by that module, you'd have to use some alternate means, like:

sketchViewModel.layer.removeAll();
FernandaBarth_EsriPT
Esri Contributor

Thank you  @JoelBennett. Didn't think about this option and works well.

0 Kudos