beforeExpand
Description
Fires before expanding an item
Usage
beforeExpand: (
id: string | number,
dir?: string
) => boolean | void;
Parameters
The callback of the event takes the following parameters:
id
- (required) the id of an itemdir
- (optional) the side the children will be shown in relation to the parent shape ("left" or "right" for type:"topic", otherwise - undefined)
Returns
Return false
to block expanding an item; otherwise, true
Example
// initializing Diagram
const diagram = new dhx.Diagram("diagram_container", {
type: "mindmap"
});
// loading data
diagram.data.parse(data);
// attaching a handler to the event
diagram.events.on("beforeExpand", (id, dir) => {
console.log("Expanding " + diagram.data.getItem(id).text, dir);
return true;
});
Change log: The dir parameter was added in v3.1
Related article: Event handling