| 1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" |
|---|
| 2 | "http://www.w3.org/TR/html4/strict.dtd"> |
|---|
| 3 | <html> |
|---|
| 4 | <head> |
|---|
| 5 | <title>Dijit Tree Programmatic Test</title> |
|---|
| 6 | |
|---|
| 7 | <style someProperty="text/css"> |
|---|
| 8 | @import "../../../dojo/resources/dojo.css"; |
|---|
| 9 | @import "../css/dijitTests.css"; |
|---|
| 10 | @import "../../../dojo/resources/dnd.css"; |
|---|
| 11 | @import "../../../dojo/tests/dnd/dndDefault.css"; |
|---|
| 12 | </style> |
|---|
| 13 | |
|---|
| 14 | <!-- required: the default dijit theme: --> |
|---|
| 15 | <link id="themeStyles" rel="stylesheet" href="../../../dijit/themes/tundra/tundra.css"> |
|---|
| 16 | |
|---|
| 17 | <!-- required: dojo.js --> |
|---|
| 18 | <script type="text/javascript" src="../../../dojo/dojo.js" |
|---|
| 19 | djConfig="isDebug: true, parseOnLoad: true"></script> |
|---|
| 20 | |
|---|
| 21 | <!-- only needed for alternate theme testing: --> |
|---|
| 22 | <script type="text/javascript" src="../_testCommon.js"></script> |
|---|
| 23 | |
|---|
| 24 | <script language="JavaScript" someProperty="text/javascript"> |
|---|
| 25 | dojo.require("dijit.dijit"); |
|---|
| 26 | dojo.require("dojo.data.ItemFileWriteStore"); |
|---|
| 27 | dojo.require("dijit.Tree"); |
|---|
| 28 | dojo.require("dijit._tree.dndSource"); |
|---|
| 29 | |
|---|
| 30 | dojo.addOnLoad(function(){ |
|---|
| 31 | myStore = new dojo.data.ItemFileWriteStore({url:'../_data/countries.json'}); |
|---|
| 32 | myModel = new dijit.tree.ForestStoreModel({ |
|---|
| 33 | store: myStore, |
|---|
| 34 | query: {type:'continent'}, |
|---|
| 35 | rootId: "earth", |
|---|
| 36 | rootLabel: "Earth", |
|---|
| 37 | childrenAttrs: ["children"] |
|---|
| 38 | }); |
|---|
| 39 | }); |
|---|
| 40 | |
|---|
| 41 | function createTree(){ |
|---|
| 42 | myTree = new dijit.Tree({ |
|---|
| 43 | id: "myTree", |
|---|
| 44 | model: myModel, |
|---|
| 45 | dndController: "dijit._tree.dndSource" |
|---|
| 46 | }); |
|---|
| 47 | dojo.byId("container").appendChild(myTree.domNode); |
|---|
| 48 | myTree.startup(); |
|---|
| 49 | dojo.byId("create").disabled = true; |
|---|
| 50 | dojo.byId("destroy").disabled = false; |
|---|
| 51 | } |
|---|
| 52 | |
|---|
| 53 | function destroyTree(){ |
|---|
| 54 | myTree.destroy(); |
|---|
| 55 | dojo.byId("create").disabled = false; |
|---|
| 56 | dojo.byId("destroy").disabled = true; |
|---|
| 57 | } |
|---|
| 58 | </script> |
|---|
| 59 | </head> |
|---|
| 60 | <body class="tundra"> |
|---|
| 61 | <h1 class="testTitle">Dijit Forest Store Programmatic Test</h1> |
|---|
| 62 | <button id="create" onclick="createTree();">Create Tree</button> |
|---|
| 63 | <button id="destroy" onclick="destroyTree();" disabled>Destroy Tree</button> |
|---|
| 64 | <div id="container"></div> |
|---|
| 65 | </body> |
|---|
| 66 | </html> |
|---|