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 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 YouThe problem in the code is that i forget to refer to childs1 after concat:
childs1=childs1.concat(childs2);
精彩评论