An interactive version of a Reingold–Tilford tree. Click on the nodes to expand or collapse. From http://bl.ocks.org/mbostock/4339083
Added search, expand and styling of results and its ancestors. Visible from http://bl.ocks.org/PBrockmann/0f22818096428b12ea23
Hello @brock,
This is awesome example of building a tree. i stuck one point and need your help.
Your search field excepting one key like searchField = "d.name"; in below example. i have multiple keys in my json so don't know how to use in your code . can u please help how i modify yr code with my json.
Your code.
//===============================================
$("#searchName").on("select2-selecting", function(e) {
clearAll(root);
expandAll(root);
update(root);
searchField = "d.name";
searchText = e.object.text;
searchTree(root);
root.children.forEach(collapseAllNotFound);
update(root);
})
if i m using searchField = "d.P"; its working to extract only all values of P .
My json
{
"M": "Mgr 1",
"children": [
{
"P": "Pub1",
"children": [
{
"S": "Site 1",
"children": [
{
"B": "Banner 1",
"children": [
{
"M": "Mgr 2",
"children": [
{
"P": "Pub 3",
"children": []
}
]
}
]
}
]
}
]
},
{
"P": "Pub2",
"size": 3333
}
]
}