Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
140
How to requery a branch after collapse/expand?
posted

We have a tree that needs to handle ~450k (and growing) potential branches. The tree is populated via "ManualSmartCallbacks" which works fine. But there a couple of things I need a hand with.

1) Is there a way to force a requery of a branch when it is collapsed and then expanded? i.e. on expand always perform the Call Back. This would handle users moving branches of the tree and other changes to the underlying data.

2) Is there a good way to remove all child nodes to free up memory on the Client PC when a node is collapsed. I tried the following but that is a) Slow (to the point of IE warnings sometimes) and b) You lose the expand ability and I cannot find a client side version of the "ShowExpand" property.

        function onNodeCollapse (treeId, nodeId) {
            node = igtree_getNodeById(nodeId);
            while (node.hasChildren()) {
                node.removeChild(0);
            }
        }
 

Parents
No Data
Reply
  • 2677
    posted

    Hello,

     There will be no way to accomplish this on the client side because there is no way to show the expander again.  Plus, trying to remove that many nodes in javascript is very time consuming.  The only way that I could think of to do this would be to handle the NodeCollapsed event on the server.  In there, we can remove the childNodes(very fast) and set the showExpand on the node again.  When I tried this out, it worked pretty good.  The DemandLoad event fired every time I expanded a node.  The only thing now is we get a postback when we collapse the node.  A quick way around that would be to wrap the WebTree in a WebAsyncRefreshPanel.  This would swallow the postback for the tree and make it asynchronous so the whole page would not have to refresh.  Hope this helps.

    Here is a code snippet of the NodeExpanded event.

    protected void UltraWebTree1_NodeCollapsed(object sender, WebTreeNodeEventArgs e)

    {

    while(e.Node.Nodes.Count > 0)

    e.Node.Nodes.RemoveAt(e.Node.Nodes.Count-1);

    e.Node.ShowExpand =
    true;

    }

Children
No Data