You have a specific structure for your TreeMap, basically you have a node with the keys id
, name
, data
and children
. As far as I read in the docs, there are no restrictions on other keys. This way you can add additional keys inside the data
attribute.
For example, your json answer might look like this:
{ "data": { "myCustomData": { } }, "id": "root", "name": "Top Albums", "children": [ { "data": { "playcount": 547, "$area": 547, "myCustomData": { } }, "id": "artist_A Perfect Circle", "name": "A Perfect Circle" } ] }
If you want to use your extra data, you do this:
... onClick: function(node) { ... if( node.data.myCustomData ){ } }
Here you have a LIVE EXAMPLE with a warning when you click on nodes with myCustomData
. hover over the do-it-yourself field in the upper left corner to see user data in a tooltip and a warning with user data when clicked.
Find the code for "mycustomdata" to find out how.
source share