开发者

remove all child elements from google org chart

i'm using google organization chart to build chart similar to the attached screenshot.

remove all child elements from google org chart

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 chil开发者_开发技巧ds 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


The problem in the code is that i forget to refer to childs1 after concat:

childs1=childs1.concat(childs2); 
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜