Skip to main content
All docs
V24.2

ASPxClientDiagram.GetItemById(id) Method

Returns a shape or connector object specified by its internal identifier.

Declaration

GetItemById(
    id: string
): DiagramItem

Parameters

Name Type Description
id string

The item identifier.

Returns

Type Description
DiagramItem

The DiagramShape or DiagramConnector object with the specified identifier.

Remarks

if(e.operation === DiagramEditOperation.DeleteShape) {
  if(e.args.shape.type === "team") {
    for(var i = 0; i < e.args.shape.attachedConnectorIds.length; i++) {
      if(s.GetItemById(e.args.shape.attachedConnectorIds[i]).toId != e.args.shape.id) {
        if(e.reason !== DiagramRequestEditOperationReason.CheckUIElementAvailability)
          showWarning("You cannot delete a 'Team' shape that has a child shape.");
        e.allowed = false;
        break;
      }
    }
  }
}

Run Demo: Editing Restrictions

If a diagram is bound to a data source, you can use the GetItemByKey(key) method to get an item by its key.

When a user pastes or clones several items in a diagram, the control adds the items to the model one by one. For each added item, the RequestEditOperation event fires. In the event handler, you can access the processed item. However, if you call the GetItemById method to access an attached connector (see the attachedConnectorIds property) or a container’s child item (see the containerChildItemIds property), you can get the undefinedresult if the item is not added to the model yet.

See Also