Search code examples
cytoscape.js

How to get collapsed nodes in cytoscape.js


I have some nodes which are grouped and collapsed. when I get nodes with cy.nodes(), I only get expanded nodes.

how to I can get all nodes that aren't expanded and not rendered in the current view?


Solution

  • I did it by using api.getCollapsedChildren(node) as written in cytoscape.js-expand-collapse document.

    let children = collapseApi.getCollapsedChildren(node);
    if (children && children.length > 0) {
       children.each((child) => {
           let nodeId = child.id();
       });
    }