Skip to main content


fires before collapsing an item

beforeCollapse: (id: Id, dir?: TreeDirection) => boolean | void;


  • id: string | number - the id of an item
  • dir: string - optional, the side the children will be hidden in relation to the parent shape ("left" or "right" for type:"topic", otherwise - undefined)


Return false to block collapsing an item; otherwise, true.

Example"beforeCollapse", function(id, dir) {
console.log("Collapsing " +, dir);
return true;

Related sample: Diagram. Org chart mode. Events

Change log:

The dir parameter has been added in v3.1.