PDA

View Full Version : Search for Node in tree



FSM
15 Feb 2010, 6:56 AM
can anyone help with my search problem. I have a search box that returns the name and id of a node in the tree.
When i click the item, i want to be able to search all nodes in the tree to match the id of the search item.
Ive tried a few different ways but if the tree has 2 parent nodes, it will check the first one and all its child nodes and that is it. The call is recursive too.

Im at a dead end really.

// this search nodes in the tree
findNode: function(node, treeid, search_id) {

if (node.hasChildNodes()) {

node = node.firstChild;
if (Ext.isObject(node)) {
node.expand(false, false, function(node) {
this.findNode(node, treeid, search_id);
}, this);
}
} else {
for (var i = 0; i < node.items.length; i++) {

var nid = node.items[i].id;
if (nid = kv) {
node.select();
}
}
}
},


// this gets called from the search
this.searchTree.on('load', function() {
this.searchTree.each(function(item) {
this.findNode(this.node,item.data.tree_ID, searchId);
}, this);
}, this);