Opened 14 years ago

Last modified 14 years ago

#5850 closed defect

Tree children are parsed incorrectly — at Initial Version

Reported by: guest Owned by:
Priority: high Milestone: 1.1
Component: Dijit Version: 1.0
Keywords: Cc:
Blocked By: Blocking:

Description

The following code block produces the following output (happens with Milestone 1.0.2, but this one cannot be selected --> I used 1.0.3 in this ticket):

Home

Top 1

  • Sub 2
  • Sub 2 Top 2

instead of

...

  • Sub 1
  • Sub 2 ...

The declaration of the references in side the children array seems to be correct (see below).

<html>
<head>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

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

<style type="text/css">

.selectedItem {
	background-color:#ccc;
}

.unselectedItem {
	background-color:#fff;
}

</style>

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

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

	dojo.declare("agitos.Tree", dijit.Tree, {

		selectedId : 0,

		getLabelClass : function(item) {
			return (item && item.id == this.selectedId) ? "selectedItem" : "unselectedItem";
		},

		onClick : function (item, node) {

			if (item) {
				this.selectedId = item.id;
				alert(item.link);
			}
		}
	});

</script>

<script type="text/javascript" charset="utf-8">

    var data = {data: {  label: 'name',
            identifier: 'name',
            items: [
                { id: '0', name:'Top 1', link:'http://0', top:true, children: [{_reference: 2}, {_reference: 3}] },
                { id: '1', name:'Top 2', link:'http://1', top:true },
                { id: '2', name:'Sub 1', link:'http://2' },
                { id: '3', name:'Sub 2', link:'http://3' }
            ]
        }};

    var menuStore=new dojo.data.ItemFileReadStore(data);

  </script>

</head>
<body class="tundra">

	<div dojoType="agitos.Tree" id="mytree" store="menuStore" label="Home" query="{top: true}"></div>

</body>
</html>

Change History (0)

Note: See TracTickets for help on using tickets.