Welcome Guest Search | Active Topics | Sign In | Register

TreeView Check All Client Side Options
quirtep
Posted: Saturday, July 26, 2008 9:27:47 AM
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.
eo_support
Posted: Saturday, July 26, 2008 9:34:49 AM
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
quirtep
Posted: Saturday, July 26, 2008 9:38:03 AM
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.
quirtep
Posted: Saturday, July 26, 2008 10:04:22 AM
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..
eo_support
Posted: Saturday, July 26, 2008 10:11:57 AM
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.html

If you just pull something out of the head without looking the reference, then it's almost for sure that it won't work.

Thanks


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.