Welcome Guest Search | Active Topics | Sign In | Register

Treeview Expand all nodes javascript Options
LLJames
Posted: Tuesday, May 27, 2008 10:30:11 AM
Rank: Newbie
Groups: Member

Joined: 5/27/2008
Posts: 3
I am trying to loop through and expand ALL using an example I saw on the forum but it only expands the first level no matter what I set the “Level” to.


function Menu1Click(e, info)
{
//var group = info.getItem().getParentGroup();
switch (info.getItem().getText())
{
case "Expand All":
toggleLevel(eo_GetObject('TreeView1').getTopGroup(), 0, true);

break;
case "Collapse All":
toggleLevel(eo_GetObject('TreeView1').getTopGroup(), 0, false);
break;
}
}



function toggleLevel(group, level, show)
{
for (var i = 0; i < group.getItemCount(); i++)
{
var item = group.getItemByIndex(i);
if (group.getLevel() <= level)
item.setExpanded(show);
else
{
var subGroup = item.getSubGroup();
if (subGroup)
toggleLevel(subGroup, level, show);
}
}
}

eo_support
Posted: Tuesday, May 27, 2008 10:40:51 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,218
Hi,

Try to change:

Code: JavaScript
if (group.getLevel() <= level)
    item.setExpanded(show); 
else
{
    var subGroup = item.getSubGroup();
    if (subGroup)
        toggleLevel(subGroup, level, show);
}


To:

Code: JavaScript
if (group.getLevel() <= level)
    item.setExpanded(show); 

var subGroup = item.getSubGroup();
if (subGroup)
    toggleLevel(subGroup, level, show);


That should get it going.

Thanks
LLJames
Posted: Tuesday, May 27, 2008 10:50:09 AM
Rank: Newbie
Groups: Member

Joined: 5/27/2008
Posts: 3
That did it. 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.