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)
}
Hi,
Try my routine, I tested it .. it works.
function UltraWebTree1_NodeChecked(treeId, nodeId, bChecked){ //Add code to handle your event here. debugger; var node = igtree_getNodeById(nodeId); var tree = igtree_getTreeById(treeId); if (!bChecked) return; debugger; if (node.getLevel() == 1) { var parent = node.getParent(); if (parent.getTag() == "Radio") { var nodes = parent.getChildNodes() for (var x = 0; x < nodes.length; x++) { if (nodes[x].Id != nodeId) { nodes[x].setChecked(false); } } } }
I found a way to put radiobutton in tree.
Create a tree with checkbox enabled. Once the tree has been populated, traverse through the tree and write the following line in your code for all child elements
igtree_getNodeById(NodeID).element.childNodes[1].outerHTML = "<INPUT TYPE='RADIO' NAME='"+ParentID+"' onclick='hello(this)'; style = \"width:10px\"\>";
This will remove the checkbox and make it a radio button, make sure you assign the ParentId correctly, that will identify the group correctly.
Also if you want to make the nodes other than leaf nodes as blank make the outerhtml for childnode 1 for that node as blank
igtree_getNodeById(NodeID).element.childNodes[1].outerHTML = "";
It is working for me.
Thanks for sharing your approach - sounds like a cool way to go. Maybe we need to add this to our DevCenter KB repository.
Thanks again.
Thanks but how do you "traverse the tree" on the client side? Id like to see a complete javascript function to do this.
This way worked better for me:
In aspx:
<ignav:UltraWebTree ID="uwtSiteTree" runat="server" CheckBoxes="True"> <ClientSideEvents NodeChecked="TreeNodeChecked"></ClientSideEvents></ignav:UltraWebTree>
In BLOCKED SCRIPT
function TreeNodeChecked(treeName, id, bChecked){ if (!bChecked) return; var tree = igtree_getTreeById(treeName); var nodes = tree.getNodes(); recursive_UncheckAllExcept( nodes, id );}function recursive_UncheckAllExcept( nodes, exceptId ){ for (var i=0; i<nodes.length; i++) { var node = nodes[i]; if( node.Id != exceptId ) node.setChecked(false); recursive_UncheckAllExcept(node.getChildNodes(), exceptId); }}