org-chart icon indicating copy to clipboard operation
org-chart copied to clipboard

Getting id of active node

Open seven700 opened this issue 2 years ago • 1 comments

Hi, in the full futuristic example found here, the onclick events for the buttoms have the node id hard coded:

  <button onclick='chart.setHighlighted("O-6162").render()'  class="btn btn-action-button waves-effect waves-light">
        <i class="fas fa-highlighter"></i> mark</button

Is there are way so that the last known active id, eg a node that has just been expanded, can be referenced in an onclick event? I might be missing something simple here, but any help would be appreciated.

seven700 avatar May 30 '22 19:05 seven700

I don't think that there is a straightforward way to do it.

Workaround: in the node update function add an additional custom event listener for the button content and save activeNode reference in the external variable

 let activeNode;

 chart.nodeUpdate(function(){
   d3.select(this).select('.node-button-g').on('click.active-node',d=>{
      activeNode = d;
    })
})

bumbeishvili avatar May 31 '22 05:05 bumbeishvili