I have a datatree with many nodes and child nodes. I use check boxes in a template. I have it set so that when you click on a node it expands and collapses. However when there is a child node that is checked I want to cancel the collapse method...
Can you help with this?
Hello Daryl,
Here is the modified function which should work for all level nodes:
function WebDataTree1_NodeCollapsing(sender, eventArgs) { var currentNode = eventArgs.getNode(); var a = 0; for (var i = 0; i < $(currentNode.get_element()).find('[type=checkbox]').length; i++) { if ($(currentNode.get_element()).find('[type=checkbox]')[i].checked) { eventArgs.set_cancel(true); } }}
Let me know if this helps.
apparently, If I click on a child node it works, but if I click on a parent node it bombs.
thanks, I ran the code, and even clicking on a parent node. I get an error.
<script type="text/jscript" language="jscript"> function wdtGeneral_NodeCollapsing(sender, eventArgs) { var node = eventArgs.getNode().get_element(); var childNodes = $(node).children("ul.igdt_NodeGroup").children("li.igdt_NodeHolder"); for (var i = 0; i < childNodes.length; i++) { if (childNodes.find('[type=checkbox]')[i].checked) { eventArgs.set_cancel(true); } } } </script>Microsoft JScript runtime error: Object expected
childNodes is undefined.
Hi Daryl007,
This could be achieved for example using jQuery:
function WebDataTree1_NodeCollapsing(sender, eventArgs){ var node = eventArgs.getNode().get_element(); var childNodes = $(node).children("ul.igdt_NodeGroup").children("li.igdt_NodeHolder"); for (var i = 0; i < childNodes.length; i++) { if (childNodes.find('[type=checkbox]')[i].checked) { eventArgs.set_cancel(true); } }}
Feel free to contact me if you have any questions.
Hi,
Thanks for the response. But I need to use templated checkboxes in this application.
Is there a way in the javascript to get deeper into the node to find out if the templated checkbox has been checked?