Opened 13 years ago

Closed 13 years ago

Last modified 12 years ago

#638 closed defect (fixed)

Adding child to tree using RPC control causes double-addition

Reported by: lcampagn@… Owned by: ilia
Priority: blocker Milestone:
Component: Widgets Version: 0.3
Keywords: Cc:
Blocked By: Blocking:

Description

I've got an RPC controlled tree based off of this example http://archive.dojotoolkit.org/nightly/tests/widget/tree/test_Tree_7.html only running a real database backend. The problem is that if I create a child on a node that has not yet been expanded, I see the created node twice--once from when it is initially created, and another from when the node is expanded.

Using nightly for 04/20

Change History (5)

comment:1 Changed 13 years ago by m.zdila@…

Milestone: 0.3.1
Priority: normalhighest
severity: normalmajor
Version: 0.20.3

this problem is still there in dojo 0.3.1 !

cause: before adding a newly created node to its parent, the parent is expanded for the first time and therefore all its children are loaded from server already including newly created node. This cause node duplication.

Here is a small "patch" that has helped me (please add it to new milestone after your additional corretions): replaced method in TreeLoadingController?.js:

doCreateChild: function(parent, index, data, callObj, callFunc) {

/* load nodes into newParent in sync mode, if needed, first */ if (parent.state == parent.loadStates.UNCHECKED) {

this.loadRemote(parent, true); parent.expand(); there is nothing to return

} else {

return dojo.widget.TreeBasicController?.prototype.doCreateChild.apply(this, arguments);

}

}

comment:2 Changed 13 years ago by bill

Milestone: 0.3.10.4
Owner: changed from anonymous to ilia

Ilia, what do you think? I'm not sure if this is a bug or not.

comment:3 Changed 13 years ago by m.zdila@…

uh! I've introduced a new bug with my "patch". Therefore a new "patch":

doCreateChild: function(parent, index, data, callObj, callFunc) {
	/* load nodes into newParent in sync mode, if needed, first */
	if (parent.state == parent.loadStates.UNCHECKED) {
		this.loadRemote(parent, true);
		this.expand(parent);
	
		if (callFunc) {
			callFunc.apply(callObj, [/*newChild*/]);
		}
		// there is nothing to return :-(
	} else {
		return dojo.widget.TreeBasicController.prototype.doCreateChild.apply(this, arguments);
	}
}

Disadvantage is that there is no new node to return if parent loads it's children and no new node to call callback fn with. I see 2 methods to workaround this:

  1. when loadRemote, do not load newly created node (in this case there would have to be some parameter to loadRemote denoting the new node)
  1. load also newly created node, but don't create it with ...doCreateChild.apply

comment:4 Changed 13 years ago by ilia

Resolution: fixed
Status: newclosed

Patch accepted into stable Tree. TreeV3 does not seem to have such problem

comment:5 Changed 12 years ago by (none)

Milestone: 0.4

Milestone 0.4 deleted

Note: See TracTickets for help on using tickets.