Opened 15 years ago

Closed 15 years ago

#4553 closed enhancement (fixed)

Tree: option where clicking label shows children

Reported by: guest Owned by: bill
Priority: high Milestone: 1.1
Component: Dijit Version: 0.9
Keywords: Tree TreeNode expand Cc:
Blocked By: Blocking:


Posted at bill's request after

A Tree that displays hierarchical data should be able to function like Windows Explorer's folder pane where clicking on a parent opens up the children below (rather than forcing a click on the expando).

Under 0.9, I was able to construct a workaround by copying the code from the prototype's expando code however I would have preferred to just call node.expand().

<div id="myTree" dojoType="dijit.Tree" store="myStore" labelAttr="label" childrenAttr="children">
  <script type="dojo/method" event="onClick" args="item,node">
    if( myList.getValue(item,"type") == "leaf") {
      /* my custom action */
      handleChildClick( myList.getValue(item, "childID"));
    } else if( node.isExpanded) {
      /* this works fine */
    } else {
      /* this doesn't work because the children aren't there yet */
      // node.expand();
      /* this works because it is copied from the expando's _onClick handler */
      dijit.byId("myTree")._publish("toggleOpen", {node:node});

Ideally this behavior could be built into the Tree control itself and toggled on or off by declaration.

Change History (3)

comment:1 Changed 15 years ago by bill

Summary: Tree: TreeNode.expand does not first populate childrenTree: option where clicking label shows children

Thanks. If this option is set to true then should the user's onClick function still be called (on non-leaf nodes)?

comment:2 Changed 15 years ago by bill

Owner: set to bill

comment:3 Changed 15 years ago by bill

Resolution: fixed
Status: newclosed

(In [11721]) Add openOnClick parameter to make clicking a folder node toggle it open/closed, rather than generating an onClick event. Fixes #4553.

Note: See TracTickets for help on using tickets.