Latest Tutorials| Questions and Answers|Ask Questions?|Site Map




Related Tutorials


 
 

Share on Google+Share on Google+

Dojo Tree

Advertisement
Complete Java Server Faces (JSF) Tutorial - JSF Tutorials. JSF Tutorials at Rose India covers everything you need to know about JSF, This JSF Tutorial contains readable and interesting content organized in proper and sequential manner. Each concept has been explained by simple examples so that you can understand easily and implement immediately into your java web application. It provides coverage of key JSF concepts such as User Interface(UI) components, Renderers, Backing beans, Validators, Converters, Navigation, Event handling, Expession language, Messages etc...

Dojo Tree

         

In this section, you will learn about the tree and how to create a tree in dojo. 

Tree :  The tree is a GUI that helps to lists the hierarchical lists. The tree widget is a simple but the real power comes in the data. It represents the hierarchical structure of tree. Data is fed by the powerful dojo.data API.

There are following steps for creating Dojo trees :

  • Create a rooted or rootless trees (forests)
  • Nest, each branch is independently expandible
  • Different icons for different leaf or branch classes
  • Tree data are stored in any dojo.data implementing API.
  • Events fire when users clicked on it.
  • Add, remove or disable nodes of tree.

Here is the code of Program:

<html>
<title>Tree</title>
<head>

  <style type="text/css">
  @import "../resources/dojo.css";
  @import "../dijit/themes/tundra/tundra.css";
  </style>

  <script type="text/javascript" src="dojo.xd.js"
djConfig="parseOnLoad: true"></script>

  <script>
  dojo.require("dojo.data.ItemFileReadStore");
  dojo.require("dijit.Tree");
  dojo.require("dojo.parser");
 </script>

</head>
<body class="tundra">
Simple Tree:<br><br>
  <div dojoType="dojo.data.ItemFileReadStore"
 url="tree.txt" jsid="popStore" />
  <div dojoType="dijit.Tree" store="popStore" 
labelAttr=
"sname" label="Tree"></div>
</body>
</html>

tree.txt: In JSON format.

{ label: 'name',
identifier: 'name',
items: [
{ name:'Students', type:'cat',
children: [
{ name:'Vinod', type:'st' },
{ name:'Suman', type:'st' },
{ name:'Deepak', type:'st' }
]

},
{ name:'Fruits', type: 'cat',
children: [
{ name:'Apple', type:'fr' },
{ name:'Mango', type:'fr' },
{ name:'Graps', type:'fr',
children: [
{ name:'Sweets', type:'gr' },
{ name:'Sour', type:'gr' },
{ name:'Salt', type:'gr' }
]

}
]

},
{ name:'Vegetables', type: 'cat'},
{ name:'Education', type:'cat'}
]
}

Output of the Program:

 

Advertisements

If you enjoyed this post then why not add us on Google+? Add us to your Circles



Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: April 18, 2011

Related Tutorials

Discuss: Dojo Tree  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:1
DINESH
September 6, 2012
DOUBT

tell me the steps to run this example file..
DMCA.com