Set Foucs to Tree (Not Item in Tree)


On a page I have a tree on, I have a input field that the user can use to search the dhtmlxTree. When the item is found, it is selected and focused in the tree. However, the actual tree is not set active itself, so if the user tries to press the spacebar, for example, that found element will not be selected. The user will have to click into the tree and then press the spacebar.

I assume there is some obvious solution I am missing, as this an inconvenience to the user and I would like to know how to workaround this in order to provide as smooth of an experience as possible for the user. I assume any solution could also be applied once the tree itself is loaded.

Thank you.

We need completed demo to reproduce your issue and help you to solve it. … leted_demo

Please see attached.

It is a correct behavior of a tree because such objects as tree (with key-navigation) can be a quantity, therefore not only tree-items could be in focus.

There is a hidden input in a tree. You can focus at it:

tree.focusItem( "code1" ); tree.selectItem( "code1" ); var inps =document.getElementById("treeCO").getElementsByTagName("INPUT"); inps[0].focus();