Welcome Guest Search | Active Topics | Sign In | Register

Finding Selected Childnodes of Childnodes... Options
Rena
Posted: Wednesday, August 27, 2008 11:42:51 AM
Rank: Newbie
Groups: Member

Joined: 3/3/2008
Posts: 1
I am using Treeview to create a dynamic menu with checkboxes. Each node may have up to 10 layers (or folders within folders) of childnodes. There is not a fixed number of layers.

When determining which items are selected, is there a programmatic solution to finding the youngest childnode in each and every folder, without having to sift through all one of them using If-Then or -Select- blocks?

Right now, I'm doing this...
**************
If xx.childnodes.count > 0 then
if xxchildnodes(i).childnodes.count > 0 then
if xx.childnodes(i).childnodes(0).childnodes.count > 0 then...and so on...
**************
and if I keep it up, I'm going to have a wildly LONG programming block.

I've tried using methods that I've used before with the System treeview, but they do not work the same way with EO.

Please help?

Thank you!
Angel
eo_support
Posted: Wednesday, August 27, 2008 11:55:57 AM
Rank: Administration
Groups: Administration

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

That'a typical scenario for a recursive function. You would do something like this:

'I am not exactly sure what you want, this is just to demonstrate the idea. So do not copy and paste

Function GetFirstYoungestCheckedNode(node)

'Walk through all child nodes first. This make sure we
'get reach the deepest node first
If node.ChildNodes.Count > 0 then
foreach (childNode in node.ChildNodes)

'Recursive call
Dim checkedNode = GetFirstYoungestCheckedNode(childNode)

'If we found one, then return directly
if checkedNode <> Nothing
return checkedNode
end for
end if

'No child is checked. Check ourself
if node.Checked
return checkedNode
else
return Nothing
end if

end

Hope this helps.

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.