Skip to main content

expand/collapse All functionality in dojo.tree

2 replies [Last post]
hovanessyan
Offline
Joined: 2008-01-15

Hi all,
is there a quick way to bind a widget-button to a jMaki-dojo-tree, so that when the button
is clicked all tree nodes expand/collapse at once ?

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
gmurray71
Offline
Joined: 2003-07-31

You can also assign an id to the root node and expand or collapse it as well.

gmurray71
Offline
Joined: 2003-07-31

Hi,

You can do using jMaki Actions. For the button use:

<div jmakiName="dojo.dijit.button"
jmakiValue="{label: 'Collapse Me',
action : { topic : '/dojo/dijit/tree/collapseNode',
message : { targetId : 'node_1_2' }}
}" ></div>

<div jmakiName="dojo.dijit.button"
jmakiValue="{label: 'Expand Me',
action : { topic : '/dojo/dijit/tree/expandNode',
message : { targetId : 'node_1_2' }}
}" ></div>

Now on the tree use:

<div jmakiName="dojo.dijit.tree"
jmakiValue="{
root : {
label : 'Tree Root Node',
expanded : true,
children : [
{ label : 'Node 1.1'},
{ label : 'Node 1.2',
id : 'node_1_2',
expanded : true,
children : [
{ label : 'Node 3.1',
action : { topic : '/foo/select', message : {targetId : 'bar'}}
}
]
}
]
}
}">
</div>

For more on the data interaction see:

http://wiki.java.net/bin/view/Projects/jMakiTreeDataModel