简体   繁体   中英

remove all child elements from google org chart

i'm using google organization chart to build chart similar to the attached screenshot.
在此输入图像描述

there is a method called removeRow(nodeIndex) that is used to remove a node from chart, but the problem is that this method only remove the node, without removing the child elements of the node.
so, for example when the user selects 3 and click remove i want to create a function that remove (3,7,8,9,10) and not only 3.
i try to create this function and this is my code:

 <script type='text/javascript'>var counter;  var childs1= new Array();</script>
<script>
 $('#remove').click(function(){

          // this method return all childs indexes for the selected node(7,10)   
         childs1=chart.getChildrenIndexes(selected_node);
         counter=childs1.length;
         for(var i=0;i< counter;i++)
             {

                 getChilds(childs1[i]);
             }
            for(var i=0;i< childs1.length;i++)
             {
              data.removeRow(childs1[i]);
             }

       })
      }

      function getChilds(child)
      {
          var childs2=new Array();
          childs2=chart.getChildrenIndexes(child);
          childs1.concat(childs2);
          counter+=childs2.length;
      }

but nothing happend. my question is: how can i create a function that returns array of all selected node children, and the chilren of each child (in this example the returned array :(3,7,8,9,10))?
Thank You

代码中的问题是我忘了在concat之后引用childs1:

childs1=childs1.concat(childs2); 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM