Skip to main content

beforeUnSelect

Description

Fires on unselecting an item, but before the item is really unselected

Usage

beforeUnSelect: (
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 unselected; 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("BeforeUnSelect", function(id) {
console.log("Unselecting " + 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