Skip to main content

beforeAdd

Description

Fires before adding an item

Usage

beforeAdd: (newItem: object) => boolean | void;

Parameters

The callback of the event takes the following parameter:

  • newItem - (required) the object of an added item

Returns

Return false to prevent adding an item into a data collection; otherwise, true

Example

// initializing Diagram
const diagram = new dhx.Diagram("diagram_container", {
type: "default"
});
// loading data
diagram.data.parse(data);

// attaching a handler to the event
diagram.events.on("beforeAdd", function(newItem){
if (some_check)
return false;
return true;
});