Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Bill Jindrich on Jul 28, 2008 05:00
open dhtmlx forum
dhtmlxtree: using findItem() fires onClick

We have been guided to use <userData> to hold the URL to each item on our website in order to 1) not have findItem() search the URL, and 2) in order to reduce the amount of data in the data XML file (we will only store the page name in <userData>, not the full path). The problem I've run into is that findItem() seems to fire the onClick() event, so each time findItem() is called, onClick is called for the matching item and the item's page is then naviagted to. But, we do not want that behavior. We want findItem() to only find and highlight the item in the tree & let the user decide if they want to navigate to the item by clicking on it. Is there a way to prevent findItem() from firing onClick() - or a least a way to differnentiate in onClick() between when findItem() is called vs. when an item is actually clicked on by the user?
Answer posted by Support on Jul 28, 2008 05:05
dhtmlxTree support two events
a) tree.findItem - find item, select it in tree and call related event
b) tree.findItemIdByLabel - find item and return its ID, item will not be selected

In your case you can use second method to find necessary item

    var id = tree.findItemIdByLabel("some");
    tree.selectItem(id,false); // select item without calling  onClick event