I want to delete a connection between two objects in draw2d.js. I am trying to find direct method that delete a connection but i did not found it. So please tell me if any way or is there any method available that delete or disconnect connection. Thanks In advance!
Asked
Active
Viewed 1,264 times
2 Answers
2
Without CommandStack
support:
canvas.remove(connection);
With CommandStack
Support (undo/redo):
var cmd = new draw2d.command.CommandDelete(connection);
canvas.getCommandStack().execute(cmd);

Gurnard
- 1,773
- 22
- 43
-
Thanks This works. But need to make one change please use correct spelling on "execute" – Harshal Chaudhari Jul 19 '12 at 10:30
0
draw2d.ContextmenuConnection.prototype.getContextMenu = function() {
var menu = new draw2d.Menu();
menu.appendMenuItem(new draw2d.MenuItem("Disconnect", null, function() {
//draw2d.Connection.workflow.removeFigure(draw2d.Connection.prototype);
var cmd = new draw2d.CommandDelete(**draw2d.Connection**);
draw2d.Connection.prototype.workflow.getCommandStack().excute(cmd);
}));
};
you must handover an object to the constructor of the CommandDelete and NOT draw2d.Connection
see below:
draw2d.ContextmenuConnection.prototype.getContextMenu = function() {
var menu = new draw2d.Menu();
var oThis = this;
menu.appendMenuItem(new draw2d.MenuItem("Disconnect", null, function() {
//draw2d.Connection.workflow.removeFigure(draw2d.Connection.prototype);
var cmd = new draw2d.CommandDelete(oThis);
draw2d.Connection.prototype.workflow.getCommandStack().excute(cmd);
}));
};