Load tree data : Tree « Dojo toolkit « JavaScript Tutorial






<html>
  <head>
    <link rel="StyleSheet" type="text/css"
      href="js/dojo/dijit/themes/tundra/tundra.css">
    <script type="text/javascript">
      var djConfig = {
        baseScriptUri : "js/dojo/",
        parseOnLoad : true
      };
    </script>
    <script type="text/javascript" src="js/dojo/dojo/dojo.js"></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:
{ label: 'name',
  identifier: 'name',
  items: [
     { name:'Name1', type:'cat',
       children: [
             { name:'1', type:'fr' },
             { name:'2', type:'fr' },
             { name:'3', type:'fr' }
       ]
     },
     { name:'Name2', type: 'cat'},
     { name:'Namr3', type:'cat'}
  ]
}








29.77.Tree
29.77.1.Load tree data