Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Tseng on Feb 29, 2008 18:03
open dhtmlx forum
focusItem fails without calling selectItem first

Hi,

I find out a strange behaviour about focusItem if it is not an undocumented feature. When I call the focusItem to give focus to an existing node on the tree, it dosen't do anything. But If I call the selectItem first, and then focusItem, it works nicely. So I wonder may be it is by design, but I can not find any document about it, so I turn to this base for help. Thanks.
Answer posted by Support on Mar 03, 2008 06:49
Actually there mustn't be any difference is focusItem used before or after selectItem, but there is a next difference in logic of commands

a) selectItem - select item in question, and open parent branches from top to item ( so if item was in closed branch - it will be opened )\
b) focusItem - scroll the tree, so the item in question will be in visible part of tree, this command will not open closed brances, so if item in question was inside closed branch - it still not be visible.

Basically, to be sure that item is not inside closed branch you can call openItem before focusItem

    tree.openItem(id);
    tree.focusItem(id)