Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Joel Finkel on Jan 26, 2009 12:11
open dhtmlx forum
tree.findItem only parses sub-tree of selected node.

Consider this code:

var a = tree.findItem("WASTEBASKET");
var b = tree.findItem("WASTEBASKET");

Result:

a != b

a is correctly set to id of the node.
b is null.

Why?

tree.findItem only parses the sub-tree of the selected node, and the first call selects the found node.

Suggestions:

1) This limitation needs to be documented.
2) Change it so that it finds all items in the entire tree, not just the selected node.
3) Provide a function that returns a sub-tree as another tree object.

Thanks.

Answer posted on Jan 27, 2009 01:37
By default findItem start search from current position in tree, so in your case, first findItem command finds item and change selection in tree, second command start from that point and doesn't find any more item with such label. 

You can 
a) use findItemIdByLabel which doesn't change selection in tree
b) use findItem with 3rd parameter as true - it will force search from top item , not from current selection.

>>only parses the sub-tree of the selected node
not exactly so, the command search through all tree except currently selected node
Answer posted by Joel Finkel on Jan 27, 2009 08:44
Thanks.  I hope that this behavior will make it into the documentation which, while quite good, is somewhat incomplete.
Answer posted by Support on Jan 27, 2009 09:09
We will update related section of documentation,  it is really not so clear in current state.