klappy
klappy

Reputation: 35

Getorgchart - Get name of clicked Node

I want to get the name of the clicked Node in the Chart. I used this sample code:

    var orgchart = new getOrgChart(document.getElementById("people"), {
  clickNodeEvent: clickHandler,
  dataSource: [{
    id: 1,
    parentId: null,
    Name: "Amber McKenzie"
  }, {
    id: 2,
    parentId: 1,
    Name: "Ava Field"
  }, {
    id: 3,
    parentId: 1,
    Name: "Evie Johnson"
  }]
});

function clickHandler(sender, args) {
  alert("clecked node.id " + args.node.id);
}

http://jsfiddle.net/GetOrgChart/jzkj2tqc/

But how can I get the name directly? Only get the id of the Current node.

Upvotes: 1

Views: 267

Answers (1)

Rob Wilkins
Rob Wilkins

Reputation: 1650

For the future, a simple way to analyse this is to use your browser's developer tools console to inspect some of the details. In this case, I was able to console.log out both the sender and args to get a view of the data that's going through -- this is done with a command along the lines of

console.log(args);

From there, you can expand the object and get a more complete view of the properties that are available to you.

In this particular case, what you'd be looking for is:

args.node.data.Name

Upvotes: 2

Related Questions