Hi!
Is it possible to allow only one selection on WebTree? I have a pretty simple hierarchical data that needs to be shown to the user in tree-view manner (only 1 level deep). I also need to let the user to check any node, so checkboxes have been enabled. However, upon checking a node, I would like all other nodes to be un--checked. Is this possible?
I wrote the following code to iterate through the tree and un-check any node that is NOT the node that's being checked but the code reports "out of memory" error. It sounds like some sort of stack-overflow-type message and I think that for some reason the handler is getting called too many times. The tree is very small (just a few nodes in Level-0, and about 5-10 nodes in Level-1).
Can someone please point out what the problem is in my code below. Thanks for any help in advance!
{
var parents = tree.getNodes();
var children = parent.getChildNodes();
child.setChecked(false)
}
I suspect you are getting the EOM error due to an infinite amount of NodeChecked events being thrown. You are listening to the NodeChecked event
and then doing
var child = children[m]; if(child.Id != nodeId)
so you aren't validating that the child is checked (and needs to be unchecked) you are just unchecking everything. This would probably end up throwing the event over and over as you keep starting the event over and over.
Thank you very much for the great advise! You were aboslutely correct. All it needed was a check for the corrent status. If anyone is interested, here is the code that works just fine. Again, this is the code to make the WebTree have check-boxes enabled, but behavior is similar to radio-button gorup (i.e. only one chekckbox can be checked at any one time). The depth of the tree is irrelevant.
if (!bChecked)
var parent = parents;
if(child.getChecked())