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://ko.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.
Random update:
That last method worked :)
I wasn't too keen on the UpdatePanel or WARP methods. I've come up with the idea of doing as below.
You'll probably all think I'm on drugs for it, but hey, maybe it'll work :).
The diagram is split between client-side methods and server-side. The entry point, "Tree_NodeChecked" is the ClientSideEvent of the WebTree.
In theory, when checking a node with multiple levels of children (with ManualSmartCallbacks), this will insert the first level of children, then allow javascript to "see" them to get their ID's, thus carrying out any client-side processes (marked red). For each newly inserted child, the process re-starts.
Hopefully, this'll look rather sweet, and have nodes appearing as they progress if the branch turns out to be quite deep. I'll report on success or failures as it happens (my time is often pulled away onto other things so this could take a few days).
Does anybody see an easier way to do this? Or see any flaws?
Hi, thanks for the feedback.
Is there any way for the client-side to know that the new nodes have been loaded in, and that all is well for the next step?
I thought to try doing it as per the image at the bottom of this post... But... I don't think it'd work. The _DemandLoad event completing does not neccessarily mean the data has completed streaming to the client, right?
Would there be any way of figuring out when (clientside eventually, but anywhere would solve the problem) the expansion of child nodes has completed?
(also, using an UpdatePanel could prove tricky, as it's already in one due to elements outside the tree requiring the tree to repopulate to different data... and the tree can get quite number of levels expanded... and our clients aren't known for fast connection speeds).
(Image on Flickr [to keep flickr happy]:http://www.flickr.com/photos/maclark/3246943641/ )