당신은 단지 (모든 것을하고, 강조 표시) 모든 노드를 찾기 위해 트리 검색 기능을 변경해야
:
\t function searchTree(obj,search,path, paths){
\t \t if(obj.name.indexOf(search) != -1){ //if search is found return, add the object to the path and return it
\t \t \t path.push(obj);
\t \t \t paths.push(path.slice(0)); // clone array
\t \t }
\t \t else if(obj.children || obj._children){ //if children are collapsed d3 object will have them instantiated as _children
\t \t \t var children = (obj.children) ? obj.children : obj._children;
\t \t \t for(var i=0;i<children.length;i++){
\t \t \t \t path.push(obj);// we assume this path is the right one \t \t \t
\t \t \t \t searchTree(children[i],search,path, paths);
\t \t \t \t path.pop();
\t \t \t }
\t \t }
\t }
...
\t $("#search").on("select2-selecting", function(e) {
\t \t var paths = [];
\t \t searchTree(root,e.object.text,[], paths);
\t \t if(paths.length > 0)
\t \t {
\t \t \t paths.forEach(function(p) { openPaths(p) });
\t \t \t //openPaths(paths);
\t \t }
\t \t else{
\t \t \t alert(e.object.text+" not found!");
\t \t }
\t })