SelectionDeleting event - Want to ask confirmation before delete

Trying to cancel SelectionDeleting Event, but event parameter does not have cancel property.
Can you please give me an example which can explain how to cancel “SelectionDeleting” Event.

I Tried with the following code, but not working.

TreeLayoutDiagram.prototype.onDiagramSelectionDeleting = function (event) {
var e = event.diagram.lastInput.event;

        e.cancelBubble = true;
        e.stopPropagation();
        e.preventDefault();
        event.cancel = true;
        return false;
    }

There is a discussion about this in the change log, GoJS Change Log.
Look for “DiagramEvent.cancel”.

Hi, Thank you for replying,
I am using GOJS version

GoJS v2.0.7 JavaScript Library for HTML Diagrams

Handled SelectionDeleting Diagram Event :- Still e.cancel property is not available.

Check the screen shot below

image
image

That’s correct – there is no “cancel” property on DiagramEvent. There used to be, but we removed it in version 2.0 because it was problematic. The change log describes how to implement the equivalent behavior.

Thank you for your help working fine now.

Sorry @walter , but I didnt find anything about that in this link: GoJS Change Log
How can I solve “confirm before delete”???
Thanks

Yes, that was from four years ago. It’s in GoJS Change Log for 2.0:

DiagramEvent.cancel

The only use for this property was with the "SelectionDeleting" DiagramEvent in order to prevent the user from deleting the selection. Where one might have written this Diagram listener:

“SelectionDeleting”: function(e) { if (e.diagram.selection.any(function(p) { return p.data.key.indexOf(“e”) >= 0; })) { e.cancel = true; } }

one can write the equivalent functionality with this CommandHandler.canDeleteSelection method override:

“commandHandler.canDeleteSelection”: function() { return !this.diagram.selection.any(function(p) { return p.data.key.indexOf(“e”) >= 0; }) && go.CommandHandler.prototype.canDeleteSelection.call(this); }

Overriding the method supports the updating/enablement of commands that call CommandHandler.deleteSelection. Furthermore not having a “cancel” property on the DiagramEvent avoids any potential problems that might occur if there are multiple listeners for the "SelectionDeleting" event. The "SelectionDeleting" DiagramEvent remains useful, but not for controlling whether or not the deletion should happen.