Quantcast

Open All Nodes in VirtualTree

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Open All Nodes in VirtualTree

FriedrichF
How is it possible to open all Nodes in an VirtualTree, which was filtered by an delegate? Delegate workes well but i am not able to open all Nodes.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Open All Nodes in VirtualTree

rsantiagopaz
hi (sorry the english)

┬┐maybe for example:

var functionOpenNode = function(node){
  var children;
        try {
                children = node.get("children");
        } catch (ex) {
                children = null;
        }
       
  if (children) {
    for (var i = children.length - 1; i >= 0; i--) {
      functionOpenNode(children.getItem(i));
    }
  }
 
  tree.openNodeAndParents(node);
};

tree.addListener("changeDelegate", function(e){
  functionOpenNode(tree.getModel());
})
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Open All Nodes in VirtualTree

FriedrichF
Thanks for this code, but this takes realy long time.

The Problem ist, that there are 7MB of Data in my VirtualTree and to open all Nodes it takes forever to open it.

But i don't wont to open the whole katalog, i implemented a search Delegate, which shows me only a part of the Tree. If i try to get the Model from the Tree after search it is still the whole Data.

So is it possible to get only the Data which is shown or is there an other way to get nodes open?
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Open All Nodes in VirtualTree

rsantiagopaz
you can use functionOpenNode with any node.

change tree.openNodeWithoutScrolling(node) instead tree.openNodeAndParents(node).
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Open All Nodes in VirtualTree

FriedrichF
Thanks for your help.

I tried it with this code:

        var searchDelegate = {};
        searchDelegate.filter = function(data) {
            var name = data.get("name").toLowerCase();
            var searchString = searchTextField.getValue().toLowerCase();
            var containsString = name.indexOf(searchString) > -1;
            var childMatchString = false;

            return (recursiveSearch(data, searchString) || containsString);
        };

        function recursiveSearch(model, searchString){
            var matchString = false;
            var childMatchString = false;

            model.get("children").forEach(function(entry) {
                var childname = entry.get("name").toLowerCase();
                if(childname.indexOf(searchString) > -1){
                    matchString = true;
                }
                childMatchString = recursiveSearch(entry, searchString);
                if(childMatchString || matchString)
                    tree.openNodeWithoutScrolling(entry);
            });

            return (childMatchString || matchString);
        }

Without the tree.openNodeWithoutScrolling the Search works well, but if i take it in i get an "Maximum call stack size exceeded".
This happens also when the matched string is in the second level only one time, so tree.openNodeWithoutScrolling(entry); should be called only one time.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Open All Nodes in VirtualTree

rsantiagopaz
maybe something like this
http://tinyurl.com/ospjfvb
or this
http://tinyurl.com/nmrjut3
regards
Loading...