beforeSelect
Description
Fires on selecting an item, but before the item is really selected
Usage
"beforeSelect": ({
id: string | number,
join: boolean,
batch: (string | number)[]
}) => boolean | void;
Parameters
The callback of the event is called with an object with the following parameters:
id
- the id of the item to selectjoin
- the applied mode of selectionbatch
- the list of items to select
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", ({ id }) => {
console.log(id + " will be selected");
return true;
});
Here's an example of attaching an event handler to the event for the Diagram Editor:
// initializing Diagram editor
const editor = new dhx.DiagramEditor("editor_container", {
// config options
});
// loading data into the editor
editor.parse(data);
// attaching a handler to the event
editor.diagram.events.on("beforeSelect", ({ id }) => {
console.log(id + " will be selected");
return true;
});
Change log: Updated in v6.0
Related articles: