Open a node with a simple click on the label


By default, we can open a node with a double click on the label.

Is it possible to do the same thing with a simple click ?



It is possible. You use openItem method to open item. This method can be called from onClick event handler:


if(tree.getOpenState(id)!=1) tree.openItem(id);


Hi, I’m using DHTMLxTree Standard. I’ve posted this code into my tree and it works great. Thanks.

  1. How would i make it do the reverse aswell?
    ie. “folder_1” is already open/expanded, you would single click on it again and it would close/retract.
  2. or If you opened/expanded a new “folder” at the same heirachy level, any open/expanded “folder” would close/retract?
    ie. single click on “folder_1” it opens/expands. single click on “folder_2” (at the same heirachy level) it opens/expands and “folder_1” would close/retract.

(Root Folder)
|-> [-] “Folder_1”
| |
| |-> “Sub_Folder_1”
|-> [+] “Folder_2”

I’m new at this so would appreciate detailed instructions on how to modify the code.



you may use the same approach:
check open state and call closeItem(id) method if it’s necessary