Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <link rel="stylesheet" type="text/css" href="http://ajax.googleapis.com/ajax/libs/dojo/1.6.1/dijit/themes/claro/claro.css"/>
- <script src="http://ajax.googleapis.com/ajax/libs/dojo/1.6.1/dojo/dojo.xd.js"></script>
- <script type="text/javascript">
- dojo.require("dojo.data.ItemFileReadStore");
- dojo.require("dijit.Tree");
- var dojo_data = {identifier: 'id', label: 'text', items: [
- {id:'-1', text:'root', children:[
- {_reference:'0'}
- ,{_reference:'1'}
- ,{_reference:'2'}]}
- ,{id: '0', text:'Zero', forestRoot: true, children: [
- {_reference:'3'}]}
- ,{id: '1', text:'One', forestRoot: true, children: [
- {_reference:'4'}]}
- ,{id: '2', text:'Two', forestRoot: true, children: [
- {_reference:'5'}]}
- ,{id: '3', text:'Three'}
- ,{id: '4', text:'Four'}
- ,{id: '5', text:'Five'}
- ]};
- dojo.ready(function ( ) {
- var data_store = new dojo.data.ItemFileReadStore({data:dojo_data});
- var tree_model = new dijit.tree.ForestStoreModel({
- rootId: '-1',
- store: data_store,
- query: {forestRoot: true},
- childrenAttrs: ["children"]});
- tree_view = new dijit.Tree(
- {model: tree_model, showRoot: false, autoExpand: true},
- 'tree_view_container');
- });
- function collapse ( )
- {
- tree_view.rootNode.getChildren()[0].collapse();
- }
- function expand ( )
- {
- tree_view.rootNode.getChildren()[0].expand();
- }
- </script>
- </head>
- <body class="claro">
- <p style="width: 30em;">Click the Collapse button. Now click the expand icon next to the collapsed node.
- Note that it will not expand. Now click the Expand button. Now click the
- expand icon next to the node multiple times. Note that it now behaves
- correctly.</p>
- <input type="button" name="Collapse" value="Collapse" onclick="collapse();"/>
- <input type="button" name="Expand" value="Expand" onclick="expand();"/>
- <div id="tree_view_container"></div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement