attach method

Diagram attach(
  1. Object props
)

This method sets a collection of properties according to the property/value pairs that have been set on the given Object, in the same manner as GraphObject.make does when constructing a Diagram with an argument that is a simple JavaScript Object.

This method does not use TypeScript compile-time type checking like Diagram#set does, but is considerably more flexible in allowing you to set sub-properties and DiagramEvents by quoted string names.

You can set properties on an object that is the value of a property of the Diagram, or on the Diagram#toolManager, Diagram#animationManager, or Diagram#commandHandler by using a "subpropname.property" syntax for the property name. At the current time only a single dot is permitted in the property "name".

The property name may also be the name of a DiagramEvent, in which case this calls #addDiagramListener with that DiagramEvent name.

aDiagram.attach({
  allowDelete: false,
  "animationManager.isEnabled": false,  // turn off automatic animations
  // specify a group membership validation predicate
  "commandHandler.memberValidation": (group, part) => ...,
  "commandHandler.copiesTree": true,  // for the copy command
  // mouse wheel zooms instead of scrolls
  "toolManager.mouseWheelBehavior": go.ToolManager.WheelZoom,
  "draggingTool.dragsTree": true,  // dragging for both move and copy
  "draggingTool.isGridSnapEnabled": true,
  layout: $(go.TreeLayout),
  // add a DiagramEvent listener
  "ExternalObjectsDropped": e => { e.subject.each(part => { ... }); }
});

@param {Object} props a plain JavaScript object with various property values to be set on this Diagram or on a part of this Diagram. @since 2.2 @return {Diagram} this Diagram @see #setProperties a synonym of this method @see #set a type-safe method to set a collection of properties

Implementation

_i3.Diagram attach(_i2.Object props) => _i4.callMethod(
      this,
      'attach',
      [props],
    );