Opened 12 years ago

Closed 12 years ago

#4469 closed defect (fixed)

Bug in dijit._tree.Controler. When a childnode is added to a not expanded treenode it is added as root-node to the tree.

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

Description

To reproduce the bug:

Using a Tree and a dojo.data.ItemFileWriteStore? as store for it. Than add 3 childs programmatically similiar to below:

var id = entries.store.newItem({name:"tt"}); var id2 = entries.store.newItem({name:"tt1"}, {parent: id, attribute:"children"}); var id3 = entries.store.newItem({name:"tt2"}, {parent: id2, attribute:"children"});

the third node is added as root node to the tree.

I think the Problem lies in the dijit._tree.Controler.onNew method. The id2 node is not added to the _itemNodeMap (because the id node is not expanded). When adding the id3 node the parent item is not found in the _itemNodeMap and the node is therefore added as root element.

I solved the problem for me by changing the line 94 from:

var childrenMap=this.tree.addChildren([childParams]);

to:

if (!parentInfo) {

var childrenMap=this.tree.addChildren([childParams]);

}

This way a node is only added as root node if it contains no parentInfo parameter.

Change History (2)

comment:1 Changed 12 years ago by bill

Milestone: 1.0
Owner: set to Dustin Machi

comment:2 Changed 12 years ago by Dustin Machi

Resolution: fixed
Status: newclosed

This item was fixed a couple weeks ago. Also this particular code location no longer exists since the tree and controller were combined.

Note: See TracTickets for help on using tickets.