Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Dan on Jun 16, 2009 05:15
open dhtmlx forum
TreeView count child nodes

Hi,

Is there a way to count the number of child nodes for a certain parent node?

Thanks.
Answer posted by Alex (support) on Jun 16, 2009 06:39

Hello, 

there is hasChildren method that returns the number of direct child items:

 var count = tree.hasChildren(itemId);

 

Answer posted by Dan on Jun 16, 2009 08:37
Thanks for this Alex.

Is there a function to determine which parent nodes have been selected?

This is so i can loop through them and check how many child nodes for each parent have been selected.

Thank you.
Answer posted by Alex (support) on Jun 17, 2009 02:09

Hello,

There are following method that return ids of checked items:

 - getAllChecked() returns the list of all checked items

in case usign 3-state checkboxes the following two methods can be also used:

 - getAllPartiallyChecked() -list of partially checked items

- getAllCheckedBranches() - list of checked and partially checked items

If you want to get "checked" state for a certain node, you can use isItemChecked(itemId) method in combination with getSubItems(id) or getAllSubItems(id)