| 1 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" |
| 2 |
"http://www.w3.org/TR/html4/strict.dtd"> |
| 3 |
<html lang="en"> |
| 4 |
<head> |
| 5 |
<meta http-equiv="Content-type" content="text/html; charset=utf-8"> |
| 6 |
<title>Dijit Tree V1 API Test</title> |
| 7 |
|
| 8 |
<style type="text/css"> |
| 9 |
@import "../../themes/claro/document.css"; |
| 10 |
@import "../css/dijitTests.css"; |
| 11 |
</style> |
| 12 |
|
| 13 |
|
| 14 |
<link id="themeStyles" rel="stylesheet" href="../../../dijit/themes/claro/claro.css"/> |
| 15 |
|
| 16 |
|
| 17 |
<script type="text/javascript" src="../../../dojo/dojo.js" |
| 18 |
data-dojo-config="isDebug: true, parseOnLoad: true"></script> |
| 19 |
|
| 20 |
|
| 21 |
<script type="text/javascript" src="../_testCommon.js"></script> |
| 22 |
|
| 23 |
<script type="text/javascript"> |
| 24 |
dojo.require("dijit.dijit"); // optimize: load dijit layer |
| 25 |
dojo.require("dojo.data.ItemFileReadStore"); |
| 26 |
dojo.require("dijit.Tree"); |
| 27 |
dojo.require("dijit.ColorPalette"); |
| 28 |
dojo.require("dojo.parser"); // scan page for widgets and instantiate them |
| 29 |
</script> |
| 30 |
</head> |
| 31 |
<body class="claro" role="main"> |
| 32 |
|
| 33 |
<h1 class="testTitle">Dijit Tree V1 API Test</h1> |
| 34 |
<p> |
| 35 |
This file is for testing the old Tree API's, where the store is specified directly |
| 36 |
rather than specifying a model which connects to a store. |
| 37 |
</p> |
| 38 |
<div dojoType="dojo.data.ItemFileReadStore" jsId="continentStore" |
| 39 |
url="../_data/countries.json"></div> |
| 40 |
|
| 41 |
<h3>Tree with hardcoded root node (not corresponding to any item in the store)</h3> |
| 42 |
<p>Clicking a folder node will open/close it (openOnclick==true), and clicking a leaf node will change the display name of the leaf node.</p> |
| 43 |
<div dojoType="dijit.Tree" id="mytree" store="continentStore" query="{type:'continent'}" |
| 44 |
onfocus="console.log('user focus handler')" |
| 45 |
onblur="console.log('user blur handler')" |
| 46 |
label="Continents" openOnClick="true" persist="false"> |
| 47 |
<script type="dojo/method" data-dojo-event="onClick" data-dojo-args="item"> |
| 48 |
this.getNodesByItem(item)[0].labelNode.innerHTML=item.name[0] + " was clicked"; |
| 49 |
</script> |
| 50 |
</div> |
| 51 |
|
| 52 |
<button onclick="dijit.byId('mytree').destroyRecursive();">destroy</button> |
| 53 |
|
| 54 |
<h2>A rootless tree (no "continents" node) with custom icons</h2> |
| 55 |
|
| 56 |
<div dojoType="dijit.Tree" id="tree2" store="continentStore" query="{type:'continent'}" persist="false"> |
| 57 |
<script type="dojo/method" event="getIconClass" args="item, opened"> |
| 58 |
return (!item || continentStore.getValue(item, "type") == "continent") ? |
| 59 |
(opened ? "customFolderOpenedIcon" : "customFolderClosedIcon") : |
| 60 |
"noteIcon"; |
| 61 |
</script> |
| 62 |
<script type="dojo/method" data-dojo-event="onClick" data-dojo-args="item"> |
| 63 |
this.getNodesByItem(item)[0].labelNode.innerHTML = item.name[0] |
| 64 |
+ " (population: " + continentStore.getValue(item, "population") +")"; |
| 65 |
</script> |
| 66 |
</div> |
| 67 |
|
| 68 |
</body> |
| 69 |
</html> |