Home >> Miscellaneous
>> DOJO-Example-Tree-Widget
Tags: DOJO Tree Widget, Dijit Tree Widget,DOJO Tutorial, DOJO Widgets, DOJO Help.
Using DOJO utility for creating a Tree widget sample.
|
|  |
|
test-dijit-tree.html
<html>
<head>
<script src="js/dojo/dojo.js" djConfig="parseOnLoad: true">
</script>
<link rel="stylesheet" type="text/css" href="js/dijit/themes/nihilo/nihilo.css"/>
<script type="text/javascript">
dojo.require("dojo.data.ItemFileReadStore");
dojo.require("dijit.Tree");
dojo.require("dijit.form.TextBox");
dojo.addOnLoad(function() {
var tmpData = [{
"name":"Refrigerator",
"submenu":
[{
"name":"Vegetables",
"submenu":[
{
"name":"Carrot",
"submenu":[]
},
{
"name":"Onion",
"submenu":[]
}
]
},
{
"name":"Fruits",
"submenu":[
{
"name":"Orange",
"submenu":[]
},
{
"name":"Apple",
"submenu":[{"name":"orange color"},
{"name":"green color"}]
}
]
}]
}];
var store = new dojo.data.ItemFileReadStore({
data: {
label: 'name',
items: tmpData
}
});
var treeModel = new dijit.tree.TreeStoreModel({
store: store,
query: {name: 'Refrigerator'},
childrenAttrs: ["submenu"]
});
new dijit.Tree({
model: treeModel
},
"TestTree");
new dijit.form.TextBox({
value: "Nihilo",
disabled: "disabled"
},
"label1");
});
</script>
</head>
<body class="nihilo">
<div id="label1">
</div>
<br/>
<div id="TestTree">
</div>
</body>
</html>
|
The above HTML source is just to show a Tree on load of this file from within
browser.
Let me explain the source code for this example from the start line to end.
I assume you can see all the different types of text colors as shown in the
above code.
The portion in green color above are for importing required widgets.
The portion in red color is the way to create data for feeding store in the
ItemFileReadStore instance. Instance of ItemFileReadStore is fed to the instance
of TreeStoreModel. Instance of TreeStoreModel is fed to the instance of the
TreeWidget.
tmpData is the variable to store the value for feeding into the Tree widget.
name is the text shown on menu and submenu decides whether to show another folder
icon or item icon.
If the submenu is left with [] then the icon changes accordingly as shown in the
screen-shot below:

In the above image items inside the Apple menu, like "orange color" and "green color",
are the fields in the tmpData variable without any submenu entires.
I have used nihilo theme in this example, you can try changing this theme to any
other supported themes such as claro/soria/tundra etc.
If anything missed out , please let me know at
techienjoy at yahoo . com
|
|
|
|
|
|
| Android Views Example : |
Example using Views using Android Platform
and source code implementing this example.
|
|
|
|
|
| Google GWT Example : |
Example using GWT and some design patterns and various
ways of implementing this example.
|
|
|
|
|
| Android Sensors Example : |
Example on Android Sensors Listed and
explained with a very simple scenario
and article with appropriate screens
captured and shown.
|
|
|
|
|
|
|
|
|
| Android Gallery Example : |
Example on Android Gallery View
explained with a very simple scenario
and appropriate screens captured and shown.
|
|
| Android Examples : |
List of ANDROid examples
with source code and output
screens captured and shown.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| Android ListView Example : |
Example on Android ListView and
explained with a very simple scenario
and article with appropriate screens
captured and shown.
|
|
|
|
| Android Canvas Example : |
Example using Canvas using Android Platform
and source code implementing this example.
|
|
| Android ListView Example : |
Example on Android ListView
explained with a very simple scenario
whereby showing folder and files with
structure and appropriate screens
captured and shown.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| Android NFC Example : |
Example using NFC using Android Platform
and source code implementing this example.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| Android GridView Example : |
Example using GridView Widget using Android Platform
and source code implementing this example.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| Android Tab View Example : |
Example on Android Tab View
explained with a very simple scenario
and appropriate screens captured and shown.
|
|
|
|
|
|
|
|
|
|
|
| Android ListView Example : |
Example on Android List View
explained with a very simple scenario
and article with appropriate screens
captured and shown.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| Android Intent Example : |
Example using Intent from Android Platform
and source code implementing this example.
|
|
|
|
|
|
|
|
|
|
|
| Android Robots Example : |
Example using Borots using Android Platform
and source code implementing this example.
|
|
| Android Draw Example : |
Example using Draw using Android Platform
and source code implementing this example.
|
|
|
|
|