Skip to main content

beforeSelect

Description

Fires on selecting an item, but before the item is really selected

Usage

beforeSelect: (
id: string | number,
subId?: string | number | undefined
) => void | boolean;

Parameters

The callback of the event takes the following parameters:

  • id - (required) the item id
  • subId - (optional) the id of a subheader of a swimlane or a text element of a line

Returns

Return false to prevent an item from being selected; otherwise, true

Example

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

// attaching a handler to the event
diagram.events.on("BeforeSelect", function(id) {
console.log("Selecting " + diagram.data.getItem(id).text);
return true;
});

Change log: The subId parameter has been added in v4.1

Related articles:

Related sample: Diagram. Org chart mode. Events