Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Tapani Jalonen on Nov 10, 2008 06:55
open dhtmlx forum
DhtmlXTree.findItem() always returns an OnClick event - how to go around this?

I have built a search, which is shown below:

findInTree = function (searchTerm) {

        //var currentId = systemOverview.findItemIdByLabel(searchTerm, 0);
        //systemOverview.selectItem(currentId, false);

        systemOverview.findItem(searchTerm, 0);

    }


The commented two lines and the findItem line are basically identical, except the commented selectItem does not fire an onClick event.

I have a need to search something in a large tree (which has a height far larger than the area, so a scrollbar appears), with these specs as to what the search should do:

1. focus and highlight that particular node, which it does nicely
2. in case the node is below the visible area and needs scrolling, autoscroll to that node.

This is not working unless I fire an onClick event as well. I tried working around findItem functionality by using the above commented lines, but I can not have autoscrolling without the onClick event. I need to be able to remove the onclick event, because I am using it for an intensive operation and do not want to launch it every time I skip to a new result. Searching without autoscroll (where the onClick is indeed turned off) is not an option, because the scrolling gets really difficult if you need to do it manually.

I hope i have described the problem accurately. Focus yes, autoscroll yes, OnClick event no.

Answer posted by Support on Nov 10, 2008 08:17
findItem execute selectItem command against found node, which fire onClick event

>>but I can not have autoscrolling without the onClick event
var currentId = systemOverview.findItemIdByLabel(searchTerm, 0);
systemOverview.selectItem(currentId,false); //select without onClick event
systemOverview.focusItem(currentId); //auto-scroll

Answer posted by Tapani Jalonen on Nov 10, 2008 08:34
Ok, now works nicely. DhtmlX components rule!