Hi Guys,
I'm struggling a bit here with the WebTree. I'm trying to get it to expand and check all nodes when a node is checked. (Expanding of children nodes isn't too important, but would be nice).
I've seen the thread "WebTree Check All Child Nodes With Demand Load" (https://es.infragistics.com/community/forums/f/retired-products-and-controls/16495/webtree-check-all-child-nodes-with-demand-load), but didn't find an answer there.
I've set up a clentside NodeChecked event, Tree_NodeChecked, which goes roughly like this...
function Tree_NodeChecked(treeId, nodeId, bCheck){ node = igtree_getNodeById(nodeId); nodeGuid = node.getDataKey(); if( bCheck == true ) { // Do my stuff Load_Model( nodeGuid ); // Expand the node node.setExpanded(true); // recursively tick/check child nodes var ChildNodes = node.getChildNodes(); if( node == null || ChildNodes.length == 0 ) { // Node has no children, do nothing. } else { for( ii = 0 ; ii < ChildNodes.length ; ii++ ) { ChildNodes[ii].setChecked( true ); Tree_NodeChecked( treeId, ChildNodes[ii].Id, true); } } } Else { // Do my stuff Delete_Model( nodeGuid ); }
However, it only seems to work with childnodes that have been pre-loaded in (those that I expand, then un-expand).
Anybody have any advice?
A bit of extra info:-
Nodes that have children, but have not yet been expanded by the user... in the above code, immediately after node.setExpanded(true), the node.getChildNodes( ) is empty :(.
This is expected behavior when using ManualSmartCallbacks (or AutomaticSmartCallbacks). The child nodes don't exist on the client until after the AJAX callback has finished, which takes time. Most likely, by the time you're trying to check the nodes, the AJAX callback hasn't yet finished, and so the child nodes don't exist yet.
I don't see any straightforward way to get this behavior when using smart callbacks. You might consider using Manual load-on-demand instead, and using either WARP or UpdatePanel to provide AJAX to the implementation.