Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#5572 closed defect (worksforme)

Tree: Bug adding new nodes

Reported by: guest Owned by:
Priority: blocker Milestone:
Component: Dijit Version: 1.0
Keywords: tree nodes Cc:
Blocked By: Blocking:

Description (last modified by bill)

This Bug appeared on the nightly build of the 11-01-2008 the behavior was OK in the nightly build of the 10-01-2008.

When I add a node programmatically, to a parent node that already has children, only the new added child is displayed after the addition. If the new node is removed, all the previous existing nodes re-appear.

For the addition of the node I used a code like:

(The identifier is: numberOfNodes (unique id))

newRoleItem=selWidget.item;

var pInfo = {parent:newRoleItem, attribute : "children"};
numberOfNodes += 1;

personObj={objid:TheNode.objid,predef:TheNode.predef,
           level:3, name:TheNode.title,nodeDocType:TheNode.nodeDocType,
           order:numberOfNodes,tree:"DistrListTree"};

treePersonItem=rootWidget.store.newItem(personObj, pInfo); 

The deletion was done using:

rootWidget.store.deleteItem(selWidget.item);

For example

parent
  child1
  child2
  child3

if I add child4, to parent, I see:

parent
  child4

if I delete child4 I see again:

parent
  child1
  child2
  child3

Eduardo

Attachments (2)

problem.gif (15.0 KB) - added by guest 11 years ago.
Tree Problem Example
5572.html (3.6 KB) - added by bill 11 years ago.
Eduardo's test case

Download all attachments as: .zip

Change History (15)

Changed 11 years ago by guest

Attachment: problem.gif added

Tree Problem Example

comment:1 Changed 11 years ago by bill

Description: modified (diff)
Summary: Bug adding new nodes to a treeTree: Bug adding new nodes

Does this reproduce for you with http://archive.dojotoolkit.org/nightly/dojotoolkit/dijit/tests/test_Tree_Notification_API_Support.html? Because it's working for me (when adding a new child to node1, at least on safari. If it works for test_Tree_Notification_API_Support.html but fails in your testcase please attach the test file using the "attach file" button. Also, was parent node opened at the time you did the insert?

comment:2 Changed 11 years ago by guest

The test_Tree_Notification_API_Support.html is working for me.

But probabily the problem is how the tree was created. Mine was created recursively, programatically and without the _reference field: like the example:

{ label: 'name',

identifier: 'name',

items: [

{ name:'Fruit', type:'category'}, { name:'Cinammon', type: 'category',

children: [

{ name:'Cinammon Roll', type:'poptart' }, { name:'Brown Sugar Cinnamon', type:'poptart' }, { name:'French Toast', type:'poptart' }

]

}, { name:'Chocolate', type: 'category'}

]

}

in javascript, something like :

theData[0]={a,b,c,d ....}; children=addChildren(TreeNodes?,numberOfNodes,level);

if(children){

theData[0].children=children;

}

where addChildren do the same until the last level is reached.

--- When I print the number of children before the new node addition, is the correct, after the addition of the new node the number of children is surprisingly "1", but when I delete the last node added to the tree, the number of children return to be as was before and the children are correctly displayed.

I saw a lot of changes in the Tree.js (specially related to childrens) and because my code worked OK until yesterday (and now also, if I replace the dojo version to the version of yesterday) I suppose that it must be an issue there. It is like the last node overwrites the sibling information, but no doubt that the information is there, because re-appears when the new node is deleted.

Have you any Idea where I need to look? Do you need any additional information I can supply. For me this is a very critical issue and I am pretty stuck until I can clarify the source of the bug. I will very appreciate if can continue with this issue even if the standard test is working also for me.

thanks

Eduardo

Eduardo

comment:3 Changed 11 years ago by guest

" Also, was parent node opened at the time you did the insert?"

This seems to have no influence in my problem. The problem occurrs in both cases (open and closed).

Eduardo

comment:4 in reply to:  2 ; Changed 11 years ago by guest

Hi

This information for sure will help. The following lines are the result of the display of: selWidget.item and selWidget.item.children[1..x](send as an attached file)

Please note that after the addition of the third node, the parent structure is correctly updated, but the new added child structure, does not include the field "children". I am not sure, if this is Dojo's or Mine bug (the source in the test Yes include this field) Can you answer me if this may be the cause and if yes and I need to set the children field, how to do it ?

Thanks

Eduardo

comment:5 in reply to:  4 Changed 11 years ago by guest

Parent after addition: objid = -1 predef = 1 level = 2 name = Others nodeDocType = role order = 16 tree = DistrListTree? children = [object Object],[object Object],[object Object] _S = [object Object] _0 = 16 _RRM = [object Object]

new child (third) Children field does not exist:

_S = [object Object] _0 = 66 order = 66 _RRM = [object Object] objid = 56 predef = 0 level = 3 name = Pepe Pistolas nodeDocType = person tree = DistrListTree?

comment:6 Changed 11 years ago by bill

I don't think that a children field is mandatory in an item (it's only needed if the item has children), but like I said above I really need you to attach a testcase using the "attach file" button.

comment:7 Changed 11 years ago by bill

PS: when writing code segments inline into the bug report or a comment field (which you shouldn't do except for small code segments), be sure to surround them with triple left braces and right braces, like I did in the description field of this bug. Thanks!

comment:8 in reply to:  7 Changed 11 years ago by guest

Hi Bill

I am not able to upload the code example, can you download the code from:

http://srv1.softwork.co.il/mytree.txt ?

thanks !!!

Eduardo

comment:9 Changed 11 years ago by guest

Hi Bill

Or I am too nervous or you are too rapid, the bug is corrected in 2008-01-12.tar.gz or at least the problem do not happen anymore in the version.

As I can see from the versions I keep in my computer, the problem comes and go, depending as function of time :). I do not know what exactely influence in this problem, but I expect that it will return in the future, so the test program is a very simple program that verifies this bug.

Anyway, thanks very much for your time !!

Eduardo

comment:10 Changed 11 years ago by Dustin Machi

Eduardo,

Bill has been hard at work over the past week making changes on the tree for several bugs/problems. You are probably just seeing some of that in the latest snapshot.

Dustin

comment:11 in reply to:  10 Changed 11 years ago by guest

Replying to dmachi:

Eduardo,

Bill has been hard at work over the past week making changes on the tree for several bugs/problems. You are probably just seeing some of that in the latest snapshot.

Dustin

He is great !! the resolution of this bug was critical in my application. You are writing an extraordinary toolkit but in addition your support is of a very high quality.

thanks again !!!

Changed 11 years ago by bill

Attachment: 5572.html added

Eduardo's test case

comment:12 Changed 11 years ago by bill

Resolution: worksforme
Status: newclosed

Hi all, thanks for the compliments :-). I uploaded http://srv1.softwork.co.il/mytree.txt as an attachment to this bug. Not sure why you weren't able do that, since you were able to upload problem.gif? (I even tried logging in as guest/guest and the "attach file" button still shows up.)

Anyway, like Dustin said I have been making a lot of changes to Tree over the past week so it's definitely possible that I broke something and then fixed it. There were also some recent changes to ItemFileWriteStore for reference integrity (removing references to an item when that item is deleted) so it's possible but somewhat unlikely that there was an issue there that got fixed.

However, having said all that, I am actually seeing an exception with your test case when the new item is deleted: the Tree.onSetItem(parent, ...) call orphans the child node, and then the Tree.onDeleteItem(child) gets confused because the child has no parent. The same problem can be seen when deleting node1.1 from http://archive.dojotoolkit.org/nightly/dojotoolkit/dijit/tests/test_Tree_Notification_API_Support.html, so I'll fix that. (Problem with [11987] checkin for #5534)

comment:13 in reply to:  12 Changed 11 years ago by guest

Hi Bill

I can see, the delete issue you mentioned. Strange in my real application everything is working OK, but not in the test case. Now I will continue with the big migration I have from 0.43 to 1.xx. I think that now I have the complete functionality I need from the Tree Widget and is working as expected (thanks to you and guys like you).

bye

Eduardo

Note: See TracTickets for help on using tickets.