|
Rank: Advanced Member Groups: Member
Joined: 9/6/2007 Posts: 133
|
I cannot figure out how to use javascript to check all the nodes in a tree. I know that there is a setting that makes it so that children will be checked when parent is checked, but I am dealing with 4 separate treeviews, and I want a single javasript function to check all nodes for all 4.
This is far as I can get:
function CheckAllExcelExport() { //Get the grid object var tree = eo_GetObject("ctl00_main_TreeViewExcelExport");
//how to loop through all nodes? //node.setChecked(1); }
THANK YOU.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,193
|
Hi, You would just write a function and call it recursively.
Code: JavaScript
function CheckNode(node)
{
//Check the node itself
node.setChecked(1);
//Check all child nodes
var subGroup = node.getSubGroup();
if (subGroup && subGroup.getItemCount())
{
for (var i = 0; i < subGroup.getItemCount(); i++)
CheckNode(subGroup.getItemByIndex(i));
}
Thanks
|
|
Rank: Advanced Member Groups: Member
Joined: 9/6/2007 Posts: 133
|
There are no child nodes, though. It's just a treeview with all nodes on the same level.
|
|
Rank: Advanced Member Groups: Member
Joined: 9/6/2007 Posts: 133
|
I'm still stumped. I tried the following, but it doesn't work either:
function CheckAllExcelExport() { var tree = eo_GetObject("ctl00_main_TreeViewExcelExport"); //Check all child nodes var subGroup = tree.getSubGroup(); if (subGroup && subGroup.getItemCount()) { for (var i = 0; i < subGroup.getItemCount(); i++) CheckNode(subGroup.getItemByIndex(i)); } }
I must be close..
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,193
|
Hi, var subGroup = tree.getSubGroup() is wrong. You should use: var subGroup = tree.getTopGroup(); You will want to go over the reference at here: http://www.essentialobjects.com/ViewDoc.aspx?t=clientapi_howto.htmlIf you just pull something out of the head without looking the reference, then it's almost for sure that it won't work. Thanks
|
|