This is a migrated thread and some comments may be shown as answers.

Checking all takes lots of time

0 Answers 101 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Robert
Top achievements
Rank 1
Robert asked on 10 Jul 2008, 07:50 PM

I have the tree view activated on this site.  It has categories in it with the all categories chack activated.  Some of the sites this is enabled on have hunderds of categories.  The problem comes in where the user clicks the "All Categories" check box and it takes an inordanent amount of time to check or uncheck all the categories.  Is there a way around this.  I am using the following modified javascript to allow for this action. 

function UpdateAllChildren( nodes, checked )  
            {  
                var i;  
                for( i = 0; i < nodes.length; i++ )  
                {  
                    if( checked )  
                    {           
                        nodes[i].Check();  
                    }  
                    else  
                    {  
                        nodes[i].UnCheck();  
                    }  
                      
                    if( nodes[i].Nodes.length > 0 )  
                    {          
                        UpdateAllChildren(nodes[i].Nodes, checked);  
                    }  
                }  
            }  
            function UpdateTopAllParent( nodes, checked )  
            {  
                var i;  
                if(nodes.length == 0){nodes[0].Nodes.UnCheck();}  
                for( i = -nodes.length; i = nodes.length; i++ )  
                {  
                    if( checked )  
                    {           
                        nodes[i - nodes.length].UnCheck();  
                    }  
                    else  
                    {  
                        nodes[i].UnCheck();  
                    }  
                      
                    if( nodes[i].length = 0 )  
                    {          
                        UpdateTopAllParent(nodes[i].Nodes, checked);  
                    }  
                }  
            }  
            function AfterCheck( node )  
            {  
                var parentNode = node.Parent;  
                var currentNode = node;  
                if(parentNode ==  null)  
                {  
                    if(node.Checked)  
                    {  
                        UpdateAllChildren( node.Nodes, true );  
                    }  
                    else  
                    {  
                        UpdateAllChildren( node.Nodes, false );  
                    }  
                }  
                else  
                {  
                    if(!node.Checked)  
                    {  
                        while(parentNode != null)  
                        {  
                                currentNode = parentNode;  
                                parentNodeparentNode = parentNode.Parent;  
                        }  
                        currentNode.UnCheck();  
                    }  
                }  
            } 

No answers yet. Maybe you can help?

Tags
TreeView
Asked by
Robert
Top achievements
Rank 1
Share this question
or