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
100
toggleCheckState Performance
posted

I have a standard edit page in my application that has in it an igTree.

 

This tree has a total of 1500 nodes and on load I need to change the checkstate to checked all of the checkboxes that meet a certain criteria that is returned from a dataset loaded via an ajax call.

 

What I'm currently doing is finding the nodes that need to be checked against the entire collection. This works fine and work as expected.

Where I'm having a problem is the actual performance of checking the checkboxes. I'm hoping there's a better way of doing this. Currently I'm iterating over the collection of nodes that need to be checked and telling igTree to check them.

    var t1 = new Date();

        var theTree = $("#tree");

        for (var i = 0; i < allMatchedNodes.length; i++) {

            theTree.igTree("toggleCheckstate", allMatchedNodes[i].element);

        }

        var t2 = new Date();

        var dif = t1.getTime() - t2.getTime();

        var Seconds_from_T1_to_T2 = dif / 1000;

        var Seconds_Between_Dates = Math.abs(Seconds_from_T1_to_T2);

 

In the example above, allMatchedNodes has a total of 36 entries and they typically have a child collection which may have another child collection (3 levels).

The problem is this takes a dreadfully long time to complete under IE8, so long in fact that you get the long running script error multiple times.

In the test cases I've run so far, the above reports 65 seconds as the running time. Am I doing something wrong attempting to check the checkboxes in this fashion?Can I remove the child collection from each top level node?

Will igTree be intelligent enough to check all children for me or does it need the children collection to check them? I'm guessing the internal toggleCheckState call is recursively iterating through the children which in this case there are up to three more levels to go through.

Your help is appreciated.   

 



 

Thank You

 

Parents
No Data
Reply
  • 5105
    Suggested Answer
    Offline posted

    Hi there,

    First of all the igTree has a checkstate that would recursively check nodes (triState) and one that keeps the checked nodes independent of each other (biState). If your issue is with the triState, meaning the recursion for the checking takes too long, then you can enable loadOnDemand. In the case of all of your data being already loaded and enabling loadOnDemand, you would actually utilize render on demand, meaning DOM elements would be created upon a node being expanded. The nodes would be rendered checked in the case of a triState checkbox mode and a checked parent. Try this out and let me know how it works!

    If you have additional questions feel free to ask!

Children