I would like to know if anyone have a sample where I get a list with all the nodes checked, Children and parents.
I would prefer getting it clients side so that I can pass it to a webservice (AJAX) and not do a postback.
If this is not the recomended way to do it, please, I am open for suggestions.
Thank you!
Hello,
This is really a very good and common case, we should include it in our samples. So the idea is to get the client-side instance of your UltraWebTree instance and use the getNodes() method to get all root nodes, the recursively call getChildNodes() for each node in order to figure out which ones are checked (via the node.getChecked()) method. More info on the UltraWebTree client-side object CSOM can be found in the online help.
Please find my sample implementation below - hope it helps:
<ignav:UltraWebTree ID="UltraWebTree1" runat="server" DefaultImage="" CheckBoxes="true" HiliteClass="" HoverClass="" Indentation="20"> <Levels> <ignav:Level Index="0" /> <ignav:Level Index="1" /> </Levels> <Nodes> <ignav:Node Text="Root Node 1"> <Nodes> <ignav:Node Text="Child Node 1.1"> </ignav:Node> <ignav:Node Text="Child Node 1.2"> </ignav:Node> <ignav:Node Text="Child Node 1.3"> </ignav:Node> </Nodes> </ignav:Node> <ignav:Node Text="Root Node 2"> <Nodes> <ignav:Node Text="Child Node 2.1"> </ignav:Node> <ignav:Node Text="Child Node 2.2"> </ignav:Node> <ignav:Node Text="Child Node 2.3"> </ignav:Node> </Nodes> </ignav:Node> <ignav:Node Text="Root Node 3"> <Nodes> <ignav:Node Text="Child Node 3.1"> </ignav:Node> <ignav:Node Text="Child Node 3.2"> </ignav:Node> <ignav:Node Text="Child Node 3.3"> </ignav:Node> </Nodes> </ignav:Node> </Nodes> </ignav:UltraWebTree> <br /><br /> <input type="button" value="Show Checked Nodes" onclick="showCheckedNodes()"/> <script type="text/javascript"> function showCheckedNodes() { var tree = igtree_getTreeById("<%= UltraWebTree1.ClientID %>"); var nodes = tree.getNodes(); recursivelyShowCheckedNodes(nodes); } function recursivelyShowCheckedNodes(nodes) { for (var i=0; i<nodes.length; i++) { var node = nodes [ i ]; if (node.getChecked()) { alert(node.getText() + " is checked"); } recursivelyShowCheckedNodes(node.getChildNodes()); } } </script>
Is there a reason this isn't available as a function call on the tree object, such as tree.getCheckedNodes()?