Select to view content in your preferred language

How to catch delete event on Editor widget.

442
3
Jump to solution
03-28-2024 04:57 AM
AnastasiiaDzundza
Occasional Contributor

Hi, I need to catch a moment when user clicks on delete after selecting feature on the map among existing. And be able to know its globalid attribute value.

Does any one has an idea how to do that?

0 Kudos
1 Solution

Accepted Solutions
ReneRubalcava
Honored Contributor

You would listen to the edits event of the Layer you are interested in. The Editor itself will not give you this information.

View solution in original post

3 Replies
ReneRubalcava
Honored Contributor

You would listen to the edits event of the Layer you are interested in. The Editor itself will not give you this information.

AnastasiiaDzundza
Occasional Contributor

Thank you a lot, for answer.

In the event that comes on 'edits', there is array of features were deleted. But int's object there is only one attribute returned 'objectId'. Screenshot 2024-04-02 at 12.40.08.png

Is there any way to configure the layer to get at list global id in this event or maybe all of the attributes?

0 Kudos
JMMFIRE
Emerging Contributor

For future reference, this is possible by overwriting the deleteFeatureFromWorkflow function. I do it like so: 

    const originalDeleteFeatureFromWorkflow = this.editor.deleteFeatureFromWorkflow;

    this.editor.deleteFeatureFromWorkflow = async () => {
      const data = this.editor.activeWorkflow.data;

      if ('rootFeature' in data) {
        const featureToDelete = data.rootFeature;

        return originalDeleteFeatureFromWorkflow.apply(this.editor, [data.rootFeature]);
      } else {
        console.warn('rootFeature is not available on the active workflow data');
      }
    };
0 Kudos