Search code examples
treeextjs4

How To Set singleClickExpand on Tree Node in ExtJS 4


The default action to expand a node on ExtJS tree is double-click.

Before version 4, there is singleClickExpand property in TreeNode configuration.

How to apply singleClickExpand behavior on ExtJS version 4 tree ??

Is there a configuration property for this behavior without setting event listener??

Thank you.


Solution

  • I've spent some time looking for the same thing. I feel I can definitively answer your question with... No there isn't a config option for it. I had to set a click handler. I needed one anyway though to implement functionality for leaf clicks:

    var tree = Ext.create('Ext.tree.Panel', {
        store: store,
        rootVisible: false,
        lines: false,
        useArrows: true,
        listeners: {
            itemclick: function(view, node) {
                if(node.isLeaf()) {
                    // some functionality to open the leaf(document) in a tabpanel
                } else if(node.isExpanded()) {
                    node.collapse();
                } else {
                    node.expand();
                }
            }
        }
    });