ASP.NET Pack Programmer's Guide
Diagram.executeCommand Method
See Also
 





Executes the specified command on this diagram.

Namespace: MindFusion.Diagramming
Package: Diagram.js

 Syntax

JavaScript  Copy Code

function executeCommand (command)

 Parameters

command

The Command to execute.

 Remarks

If undo/redo is enabled, the command is saved in the undo history or added to the active composite command.

AddItemCommand and RemoveItemCommand objects are created automatically by the control when adding or removing items, both programmatically or interactively. Calling this method explicitly could be necessary in order to save item's state for later undo using a ChangeItemCommand, or to run a custom operation represented by a class derived from Command.

 Example

The following example shows the pattern that should be used to save the state of an item for later undo.

JavaScript  Copy Code

var ChangeItemCommand = MindFusion.Diagramming.ChangeItemCommand;
var DiagramNode = MindFusion.Diagramming.DiagramNode;

var diagram = $find("diagram");
var node = diagram.getActiveItem();
if (DiagramNode.isInstanceOfType(node))
{
    var change = new ChangeItemCommand(diagram, node);
    node.setText("new text");
    node.setBrush("red");
    diagram.executeCommand(change);
}

 See Also

Diagram Members
Diagram Class
MindFusion.Diagramming Namespace
UndoEnabled Property
undo Method
startCompositeOperation Method