2

Hi I am using this ( http://react-component.github.io/tree/examples/dynamic.html ) example to create a dynamic tree. I am new to reactJS. In the Api description it is mentioned that we can use string/element as title. In this example string is used as treenode, I want to use element as a treenode because i want to display more information with the title name. Can anyone help me out where to start with or where to add element code so it will display for all the parent and child node.

Thanks in advance.

1 Answer 1

2

In the render() function in place of return <TreeNode title={item.name} key={item.key}>{loop(item.children)}</TreeNode>; You can use <TreeNode className="data-loop" title={myElement(item.name,item.address,item.age)} key={item.key}>{loop(item.children)}</TreeNode> and define your 'myElement' like

var myElement =(name,address,age) =>{
      return (
        <span>
          Name: {name} <br/>
          address:{address} <br/>
          Age: {age}
          </span>

        )
    }
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.