Opened 12 years ago

Closed 12 years ago

#5850 closed defect (invalid)

Tree: children are parsed incorrectly

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

Description (last modified by bill)

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 (4)

comment:1 Changed 12 years ago by Adam Peller

Milestone: 1.0.31.1

comment:2 Changed 12 years ago by bill

Owner: set to bill
Summary: Tree children are parsed incorrectlyTree: children are parsed incorrectly

comment:3 Changed 12 years ago by bill

Description: modified (diff)

comment:4 Changed 12 years ago by bill

Resolution: invalid
Status: newclosed

There's an error in your data. Instead of identifier: 'name' you should have identifier: 'id'. Also there's an inconsistency where your ids are strings, but your _references are numbers. After fixing that, this works fine, at least on trunk.

Note: See TracTickets for help on using tickets.