[Users] Treepanel node search?

5 views
Skip to first unread message

Robert Buckley

unread,
Mar 14, 2012, 3:44:06 AM3/14/12
to us...@geoext.org
Hi,

Has anyone developed a simple treepanel search which iterates through a treepanel and finds the node.text?

I can iterate through, but am not sure how to get the results to do anything usefull....ie..if 5 results are found, it would be necessary to then either open parent container , switch visibility to true and zoom to extent for the selected node.

Any help would be great,

cheers,

Rob

Robert Buckley

unread,
Mar 14, 2012, 5:12:45 AM3/14/12
to Peter...@tba.llv.li, us...@geoext.org
Hi,

Thanks for the code.

I have a treepanel which has (or will have) over 100 layers. In order that the user can find a layer quicker I wanted to develop I little search tool which will iterate through the treepanel looking for the search string and match it with the treenode.text (name of the layer). When matches are found these should be listed so that the user can click on one of the results, open the parent and display the layer.

Quite a tall order.

yours,

Rob



Von: "Peter...@tba.llv.li" <Peter...@tba.llv.li>
An: robertd...@yahoo.com
Gesendet: 9:57 Mittwoch, 14.März 2012
Betreff: AW: [Users] Treepanel node search?

Hi Robert
I'm not sure, what you are looking for. Probably your are looking for something else, but I post some code that I use to crawl trough a tree an do something with the leaves. Maybe it will help you
Regards
Peter
 
var rootNode=layerTree.getRootNode();
rootNode.eachChild(function (myNode) {
   myNode.collapse();
   myNode.eachChild(function (n) {
                      for (i=0; i < n.layer.params.LAYERS.length; i++) {
                         if (n.layer.params.LAYERS[i] == n.text ) {
                              n.setText( 'test');
                         }
                  }
                  n.disable();
   });
});
Reply all
Reply to author
Forward
0 new messages