Skip to main content



Fires after an item has been collapsed


afterCollapse: (
id: string | number,
dir?: string
) => void;


The callback of the event takes the following parameters:

  • id - (required) the id of an item which has been collapsed
  • dir - (optional) the side the children were hidden in relation to the parent shape ("left" or "right" for type:"topic", otherwise - undefined)


// initializing Diagram
const diagram = new dhx.Diagram("diagram_container", {
type: "default"
// loading data;

// attaching a handler to the event"afterCollapse", function(id, dir) {
console.log( + " was collapsed", dir);

Change log: The dir parameter has been added in v3.1

Related article: Event handling

Related sample: Diagram. Org chart mode. Events